public class C3p0PoolingConnectionProvider extends java.lang.Object implements PoolingConnectionProvider
A ConnectionProvider implementation that creates its own
pool of connections.
This class uses C3PO (http://www.mchange.com/projects/c3p0/index.html) as the underlying pool implementation.
DBConnectionManager,
ConnectionProvider| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DB_DISCARD_IDLE_CONNECTIONS_SECONDS
Discard connections after they have been idle this many seconds.
|
static java.lang.String |
DB_IDLE_VALIDATION_SECONDS
The number of seconds between tests of idle connections - only enabled
if the validation query property is set.
|
static java.lang.String |
DB_MAX_CACHED_STATEMENTS_PER_CONNECTION
The maximum number of prepared statements that will be cached per connection in the pool.
|
static java.lang.String |
DB_VALIDATE_ON_CHECKOUT
Whether the database sql query to validate connections should be executed every time
a connection is retrieved from the pool to ensure that it is still valid.
|
static int |
DEFAULT_DB_MAX_CACHED_STATEMENTS_PER_CONNECTION
Default maximum number of database connections in the pool.
|
DB_DRIVER, DB_MAX_CONNECTIONS, DB_PASSWORD, DB_URL, DB_USER, DB_VALIDATION_QUERY, DEFAULT_DB_MAX_CONNECTIONS, POOLING_PROVIDER, POOLING_PROVIDER_C3P0, POOLING_PROVIDER_HIKARICP| Constructor and Description |
|---|
C3p0PoolingConnectionProvider(java.util.Properties config)
Create a connection pool using the given properties.
|
C3p0PoolingConnectionProvider(java.lang.String dbDriver,
java.lang.String dbURL,
java.lang.String dbUser,
java.lang.String dbPassword,
int maxConnections,
java.lang.String dbValidationQuery) |
| Modifier and Type | Method and Description |
|---|---|
java.sql.Connection |
getConnection() |
com.mchange.v2.c3p0.ComboPooledDataSource |
getDataSource()
Get the C3PO ComboPooledDataSource created during initialization.
|
void |
initialize() |
void |
shutdown() |
public static final java.lang.String DB_MAX_CACHED_STATEMENTS_PER_CONNECTION
public static final java.lang.String DB_IDLE_VALIDATION_SECONDS
public static final java.lang.String DB_VALIDATE_ON_CHECKOUT
public static final java.lang.String DB_DISCARD_IDLE_CONNECTIONS_SECONDS
public static final int DEFAULT_DB_MAX_CACHED_STATEMENTS_PER_CONNECTION
public C3p0PoolingConnectionProvider(java.lang.String dbDriver,
java.lang.String dbURL,
java.lang.String dbUser,
java.lang.String dbPassword,
int maxConnections,
java.lang.String dbValidationQuery)
throws java.sql.SQLException,
SchedulerException
java.sql.SQLExceptionSchedulerExceptionpublic C3p0PoolingConnectionProvider(java.util.Properties config)
throws SchedulerException,
java.sql.SQLException
The properties passed should contain:
PoolingConnectionProvider.DB_DRIVER- The database driver class name
PoolingConnectionProvider.DB_URL- The database URL
PoolingConnectionProvider.DB_USER- The database user
PoolingConnectionProvider.DB_PASSWORD- The database password
PoolingConnectionProvider.DB_MAX_CONNECTIONS- The maximum # connections in the pool,
optional
PoolingConnectionProvider.DB_VALIDATION_QUERY- The sql validation query, optional
config - configuration propertiesSchedulerExceptionjava.sql.SQLExceptionpublic com.mchange.v2.c3p0.ComboPooledDataSource getDataSource()
This can be used to set additional data source properties in a subclass's constructor.
getDataSource in interface PoolingConnectionProviderpublic java.sql.Connection getConnection()
throws java.sql.SQLException
getConnection in interface ConnectionProviderjava.sql.SQLExceptionpublic void shutdown()
throws java.sql.SQLException
shutdown in interface ConnectionProviderjava.sql.SQLExceptionpublic void initialize()
throws java.sql.SQLException
initialize in interface ConnectionProviderjava.sql.SQLExceptionCopyright IBM Corp. 2024, 2025