Top Description Fields Constructors Methods
org.h2.util

public Class OsgiDataSourceFactory

extends Object
implements DataSourceFactory
Class Inheritance
All Implemented Interfaces
org.osgi.service.jdbc.DataSourceFactory
Imports
java.sql.SQLException, .SQLFeatureNotSupportedException, java.util.Hashtable, .Properties, javax.sql.ConnectionPoolDataSource, .DataSource, .XADataSource, org.h2.engine.Constants, org.h2.jdbcx.JdbcDataSource, org.osgi.framework.BundleContext, org.osgi.service.jdbc.DataSourceFactory

This class implements the OSGi DataSourceFactory interface for the H2 JDBC driver. The following standard configuration properties are supported: JDBC_USER, JDBC_PASSWORD, JDBC_DESCRIPTION, JDBC_DATASOURCE_NAME, JDBC_NETWORK_PROTOCOL, JDBC_URL, JDBC_SERVER_NAME, JDBC_PORT_NUMBER. The following standard configuration properties are not supported: JDBC_ROLE_NAME, JDBC_DATABASE_NAME, JDBC_INITIAL_POOL_SIZE, JDBC_MAX_POOL_SIZE, JDBC_MIN_POOL_SIZE, JDBC_MAX_IDLE_TIME, JDBC_MAX_STATEMENTS, JDBC_PROPERTY_CYCLE. Any other property will be treated as a H2 specific option. If the JDBC_URL property is passed to any of the DataSource factories, the following properties will be ignored: JDBC_DATASOURCE_NAME, JDBC_NETWORK_PROTOCOL, JDBC_SERVER_NAME, JDBC_PORT_NUMBER.
Author
Per Otterstrom

Field Summary

Modifier and TypeField and Description
private final Driver

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ConnectionPoolDataSource

Returns:

a new data source.
createConnectionPoolDataSource
(Properties
the properties for the data source.
properties
)

Implements org.osgi.service.jdbc.DataSourceFactory.createConnectionPoolDataSource.

Creates a pooled data source.

public DataSource

Returns:

a new data source.
createDataSource
(Properties
the properties for the data source.
properties
)

Implements org.osgi.service.jdbc.DataSourceFactory.createDataSource.

Creates a basic data source.

public Driver

Returns:

a driver.
createDriver
(Properties
must be null or empty list.
properties
)

Implements org.osgi.service.jdbc.DataSourceFactory.createDriver.

Returns a driver.

public XADataSource

Returns:

a new data source.
createXADataSource
(Properties
the properties for the data source.
properties
)

Implements org.osgi.service.jdbc.DataSourceFactory.createXADataSource.

Creates a pooled XA data source.

pack-priv static void
registerService(BundleContext
the bundle context
bundleContext
,
Driver
the driver
driver
)

Register the H2 JDBC driver service.

private static void
rejectPoolingOptions(Properties
the properties to check
p
)

Checker method that will throw if any pooling related standard OSGi options are present.

private static void
rejectUnsupportedOptions(Properties
the properties to check
p
)

Checker method that will throw if any unsupported standard OSGi options is present.

private static void
setupH2DataSource(JdbcDataSource
the data source to configure
dataSource
,
Properties
the properties to apply to the data source
p
)

Applies common OSGi properties to a H2 data source.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

driverback to summary
private final Driver driver

Constructor Detail

OsgiDataSourceFactoryback to summary
public OsgiDataSourceFactory(Driver driver)

Method Detail

createConnectionPoolDataSourceback to summary
public ConnectionPoolDataSource createConnectionPoolDataSource(Properties properties) throws SQLException

Implements org.osgi.service.jdbc.DataSourceFactory.createConnectionPoolDataSource.

Creates a pooled data source.

Parameters
properties:Properties

the properties for the data source.

Returns:ConnectionPoolDataSource

a new data source.

Annotations
@Override
Exceptions
SQLException:
if unsupported properties are supplied, or if data source can not be created.
createDataSourceback to summary
public DataSource createDataSource(Properties properties) throws SQLException

Implements org.osgi.service.jdbc.DataSourceFactory.createDataSource.

Creates a basic data source.

Parameters
properties:Properties

the properties for the data source.

Returns:DataSource

a new data source.

Annotations
@Override
Exceptions
SQLException:
if unsupported properties are supplied, or if data source can not be created.
createDriverback to summary
public Driver createDriver(Properties properties) throws SQLException

Implements org.osgi.service.jdbc.DataSourceFactory.createDriver.

Returns a driver. The H2 driver does not support any properties.

Parameters
properties:Properties

must be null or empty list.

Returns:Driver

a driver.

Annotations
@Override
Exceptions
SQLException:
if any property is supplied.
createXADataSourceback to summary
public XADataSource createXADataSource(Properties properties) throws SQLException

Implements org.osgi.service.jdbc.DataSourceFactory.createXADataSource.

Creates a pooled XA data source.

Parameters
properties:Properties

the properties for the data source.

Returns:XADataSource

a new data source.

Annotations
@Override
Exceptions
SQLException:
if unsupported properties are supplied, or if data source can not be created.
registerServiceback to summary
pack-priv static void registerService(BundleContext bundleContext, Driver driver)

Register the H2 JDBC driver service.

Parameters
bundleContext:BundleContext

the bundle context

driver:Driver

the driver

rejectPoolingOptionsback to summary
private static void rejectPoolingOptions(Properties p) throws SQLFeatureNotSupportedException

Checker method that will throw if any pooling related standard OSGi options are present.

Parameters
p:Properties

the properties to check

Exceptions
SQLFeatureNotSupportedException:
if unsupported properties are present
rejectUnsupportedOptionsback to summary
private static void rejectUnsupportedOptions(Properties p) throws SQLFeatureNotSupportedException

Checker method that will throw if any unsupported standard OSGi options is present.

Parameters
p:Properties

the properties to check

Exceptions
SQLFeatureNotSupportedException:
if unsupported properties are present
setupH2DataSourceback to summary
private static void setupH2DataSource(JdbcDataSource dataSource, Properties p)

Applies common OSGi properties to a H2 data source. Non standard properties will be applied as H2 options.

Parameters
dataSource:JdbcDataSource

the data source to configure

p:Properties

the properties to apply to the data source