Package org.h2.util

Class OsgiDataSourceFactory

java.lang.Object
org.h2.util.OsgiDataSourceFactory
All Implemented Interfaces:
org.osgi.service.jdbc.DataSourceFactory

public class OsgiDataSourceFactory extends Object implements org.osgi.service.jdbc.DataSourceFactory
This class implements the OSGi DataSourceFactory interface for the H2 JDBC driver. The following standard configuration properties are supported: DataSourceFactory.JDBC_USER, DataSourceFactory.JDBC_PASSWORD, DataSourceFactory.JDBC_DESCRIPTION, DataSourceFactory.JDBC_DATASOURCE_NAME, DataSourceFactory.JDBC_NETWORK_PROTOCOL, DataSourceFactory.JDBC_URL, DataSourceFactory.JDBC_SERVER_NAME, DataSourceFactory.JDBC_PORT_NUMBER. The following standard configuration properties are not supported: DataSourceFactory.JDBC_ROLE_NAME, DataSourceFactory.JDBC_DATABASE_NAME, DataSourceFactory.JDBC_INITIAL_POOL_SIZE, DataSourceFactory.JDBC_MAX_POOL_SIZE, DataSourceFactory.JDBC_MIN_POOL_SIZE, DataSourceFactory.JDBC_MAX_IDLE_TIME, DataSourceFactory.JDBC_MAX_STATEMENTS, DataSourceFactory.JDBC_PROPERTY_CYCLE. Any other property will be treated as an H2 specific option. If the DataSourceFactory.JDBC_URL property is passed to any of the DataSource factories, the following properties will be ignored: DataSourceFactory.JDBC_DATASOURCE_NAME, DataSourceFactory.JDBC_NETWORK_PROTOCOL, DataSourceFactory.JDBC_SERVER_NAME, DataSourceFactory.JDBC_PORT_NUMBER.
  • Constructor Details

    • OsgiDataSourceFactory

      public OsgiDataSourceFactory(Driver driver)
  • Method Details

    • createDataSource

      public DataSource createDataSource(Properties properties) throws SQLException
      Creates a basic data source.
      Specified by:
      createDataSource in interface org.osgi.service.jdbc.DataSourceFactory
      Parameters:
      properties - the properties for the data source.
      Returns:
      a new data source.
      Throws:
      SQLException - if unsupported properties are supplied, or if data source can not be created.
    • createConnectionPoolDataSource

      public ConnectionPoolDataSource createConnectionPoolDataSource(Properties properties) throws SQLException
      Creates a pooled data source.
      Specified by:
      createConnectionPoolDataSource in interface org.osgi.service.jdbc.DataSourceFactory
      Parameters:
      properties - the properties for the data source.
      Returns:
      a new data source.
      Throws:
      SQLException - if unsupported properties are supplied, or if data source can not be created.
    • createXADataSource

      public XADataSource createXADataSource(Properties properties) throws SQLException
      Creates a pooled XA data source.
      Specified by:
      createXADataSource in interface org.osgi.service.jdbc.DataSourceFactory
      Parameters:
      properties - the properties for the data source.
      Returns:
      a new data source.
      Throws:
      SQLException - if unsupported properties are supplied, or if data source can not be created.
    • createDriver

      public Driver createDriver(Properties properties) throws SQLException
      Returns a driver. The H2 driver does not support any properties.
      Specified by:
      createDriver in interface org.osgi.service.jdbc.DataSourceFactory
      Parameters:
      properties - must be null or empty list.
      Returns:
      a driver.
      Throws:
      SQLException - if any property is supplied.