com.mchange.v2.c3p0

Class PoolBackedDataSourceFactory


public final class PoolBackedDataSourceFactory
extends java.lang.Object

A class offering Factory methods for creating DataSources backed by Connection and Statement Pools.

Method Summary

static DataSource
create(DataSource unpooledDataSource)
Creates a pool-backed DataSource using unpooledDataSource as its source for Connections and default values for pool params.
static DataSource
create(DataSource unpooledDataSource, int minPoolSize, int maxPoolSize, int acquireIncrement, int maxIdleTime, int maxStatements)
Creates a pool-backed DataSource using unpooledDataSource as its source for Connections.
static DataSource
create(DataSource unpooledDataSource, int minPoolSize, int maxPoolSize, int acquireIncrement, int maxIdleTime, int maxStatements, String factoryLocation)
Creates a pool-backed DataSource using unpooledDataSource as its source for Connections.
static DataSource
create(String jdbcUrl, String user, String password)
Creates a pool-backed DataSource using default pool parameters.
static DataSource
create(String jdbcDriverClass, String jdbcUrl, String user, String password)
Creates a pool-backed DataSource using default values for pool parameters.
static DataSource
create(String jdbcDriverClass, String jdbcUrl, String user, String password, int minPoolSize, int maxPoolSize, int acquireIncrement, int maxIdleTime, int maxStatements)
Creates a pool-backed DataSource.
static DataSource
create(String jdbcDriverClass, String jdbcUrl, String user, String password, int minPoolSize, int maxPoolSize, int acquireIncrement, int maxIdleTime, int maxStatements, String factoryLocation)
Creates a pool-backed DataSource.
static DataSource
create(String jdbcUrl, String user, String password, int minPoolSize, int maxPoolSize, int acquireIncrement, int maxIdleTime, int maxStatements)
Creates a pool-backed DataSource.
static DataSource
create(String jdbcUrl, String user, String password, int minPoolSize, int maxPoolSize, int acquireIncrement, int maxIdleTime, int maxStatements, String factoryLocation)
Creates a pool-backed DataSource.
static DataSource
createReferenceable(DataSource unpooledDataSource, String factoryLocation)
Deprecated. all implementations are now both Referenceable and Serializable.
static DataSource
createReferenceable(DataSource unpooledDataSource, int minPoolSize, int maxPoolSize, int acquireIncrement, int maxIdleTime, int maxStatements, String factoryLocation)
Deprecated. all implementations are now both Referenceable and Serializable.
static DataSource
createReferenceable(String jdbcDriverClass, String jdbcUrl, String user, String password, String factoryLocation)
Deprecated. all implementations are now both Referenceable and Serializable.
static DataSource
createReferenceable(String jdbcDriverClass, String jdbcUrl, String user, String password, int minPoolSize, int maxPoolSize, int acquireIncrement, int maxIdleTime, int maxStatements, String factoryLocation)
Deprecated. all implementations are now both Referenceable and Serializable.
static DataSource
createSerializable(DataSource unpooledDataSource)
Deprecated. all implementations are now both Referenceable and Serializable.
static DataSource
createSerializable(DataSource unpooledDataSource, int minPoolSize, int maxPoolSize, int acquireIncrement, int maxIdleTime, int maxStatements)
Deprecated. all implementations are now both Referenceable and Serializable.
static DataSource
createSerializable(String jdbcDriverClass, String jdbcUrl, String user, String password)
Deprecated. all implementations are now both Referenceable and Serializable.
static DataSource
createSerializable(String jdbcDriverClass, String jdbcUrl, String user, String password, int minPoolSize, int maxPoolSize, int acquireIncrement, int maxIdleTime, int maxStatements)
Deprecated. all implementations are now both Referenceable and Serializable.

Method Details

create

public static DataSource create(DataSource unpooledDataSource)
            throws SQLException
Creates a pool-backed DataSource using unpooledDataSource as its source for Connections and default values for pool params.
Parameters:
unpooledDataSource - an unpooledDataSource to use as the primary source for connections.

create

public static DataSource create(DataSource unpooledDataSource,
                                int minPoolSize,
                                int maxPoolSize,
                                int acquireIncrement,
                                int maxIdleTime,
                                int maxStatements)
            throws SQLException
Creates a pool-backed DataSource using unpooledDataSource as its source for Connections. Not necessarily suitable for JNDI binding.
Parameters:
unpooledDataSource - an unpooledDataSource to use as the primary source for connections.
minPoolSize - the minimum (and starting) number of Connections that should be held in the pool.
maxPoolSize - the maximum number of Connections that should be held in the pool.
acquireIncrement - the number of Connections that should be acquired at a time when the pool runs out of Connections
maxIdleTime - the maximum number of seconds a Connection should be allowed to remain idle before it is expired from the pool. A value of 0 means Connections never expire.
maxStatements - the maximum number of PreparedStatements that should be cached by this pool. A value of 0 means that Statement caching should be disabled.

create

public static DataSource create(DataSource unpooledDataSource,
                                int minPoolSize,
                                int maxPoolSize,
                                int acquireIncrement,
                                int maxIdleTime,
                                int maxStatements,
                                String factoryLocation)
            throws SQLException
Creates a pool-backed DataSource using unpooledDataSource as its source for Connections. Not necessarily suitable for JNDI binding.
Parameters:
unpooledDataSource - an unpooledDataSource to use as the primary source for connections.
minPoolSize - the minimum (and starting) number of Connections that should be held in the pool.
maxPoolSize - the maximum number of Connections that should be held in the pool.
acquireIncrement - the number of Connections that should be acquired at a time when the pool runs out of Connections
maxIdleTime - the maximum number of seconds a Connection should be allowed to remain idle before it is expired from the pool. A value of 0 means Connections never expire.
maxStatements - the maximum number of PreparedStatements that should be cached by this pool. A value of 0 means that Statement caching should be disabled.
factoryLocation - a codebase url where JNDI clients can find the c3p0 libraries. Use null if clients will be expected to have the libraries available locally. Used only if the JNDI service prefers References to Serialized Objects when Objects are bound.

create

public static DataSource create(String jdbcUrl,
                                String user,
                                String password)
            throws SQLException
Creates a pool-backed DataSource using default pool parameters.

Warning: If you use this method, you must make sure a JDBC driver capable of resolving jdbcUrl has been preloaded!

Parameters:
jdbcUrl - the jdbcUrl of the RDBMS that Connections should be made to.
user - a username (may be null) for authentication to the RDBMS
password - a password (may be null) for authentication to the RDBMS

create

public static DataSource create(String jdbcDriverClass,
                                String jdbcUrl,
                                String user,
                                String password)
            throws SQLException
Creates a pool-backed DataSource using default values for pool parameters. Not necessarily suitable for JNDI binding.
Parameters:
jdbcDriverClass - a jdbc driver class that can resolve jdbcUrl.
jdbcUrl - the jdbcUrl of the RDBMS that Connections should be made to.
user - a username (may be null) for authentication to the RDBMS
password - a password (may be null) for authentication to the RDBMS

create

public static DataSource create(String jdbcDriverClass,
                                String jdbcUrl,
                                String user,
                                String password,
                                int minPoolSize,
                                int maxPoolSize,
                                int acquireIncrement,
                                int maxIdleTime,
                                int maxStatements)
            throws SQLException
Creates a pool-backed DataSource.
Parameters:
jdbcDriverClass - a jdbc driver class that can resolve jdbcUrl.
jdbcUrl - the jdbcUrl of the RDBMS that Connections should be made to.
user - a username (may be null) for authentication to the RDBMS
password - a password (may be null) for authentication to the RDBMS
minPoolSize - the minimum (and starting) number of Connections that should be held in the pool.
maxPoolSize - the maximum number of Connections that should be held in the pool.
acquireIncrement - the number of Connections that should be acquired at a time when the pool runs out of Connections
maxIdleTime - the maximum number of seconds a Connection should be allowed to remain idle before it is expired from the pool. A value of 0 means Connections never expire.
maxStatements - the maximum number of PreparedStatements that should be cached by this pool. A value of 0 means that Statement caching should be disabled.

create

public static DataSource create(String jdbcDriverClass,
                                String jdbcUrl,
                                String user,
                                String password,
                                int minPoolSize,
                                int maxPoolSize,
                                int acquireIncrement,
                                int maxIdleTime,
                                int maxStatements,
                                String factoryLocation)
            throws SQLException
Creates a pool-backed DataSource.
Parameters:
jdbcDriverClass - a jdbc driver class that can resolve jdbcUrl.
jdbcUrl - the jdbcUrl of the RDBMS that Connections should be made to.
user - a username (may be null) for authentication to the RDBMS
password - a password (may be null) for authentication to the RDBMS
minPoolSize - the minimum (and starting) number of Connections that should be held in the pool.
maxPoolSize - the maximum number of Connections that should be held in the pool.
acquireIncrement - the number of Connections that should be acquired at a time when the pool runs out of Connections
maxIdleTime - the maximum number of seconds a Connection should be allowed to remain idle before it is expired from the pool. A value of 0 means Connections never expire.
maxStatements - the maximum number of PreparedStatements that should be cached by this pool. A value of 0 means that Statement caching should be disabled.
factoryLocation - a codebase url where JNDI clients can find the c3p0 libraries. Use null if clients will be expected to have the libraries available locally. Used only if the JNDI service prefers References to Serialized Objects when Objects are bound.

create

public static DataSource create(String jdbcUrl,
                                String user,
                                String password,
                                int minPoolSize,
                                int maxPoolSize,
                                int acquireIncrement,
                                int maxIdleTime,
                                int maxStatements)
            throws SQLException
Creates a pool-backed DataSource.

Warning: If you use this method, you must make sure a JDBC driver capable of resolving jdbcUrl has been preloaded!

Parameters:
jdbcUrl - the jdbcUrl of the RDBMS that Connections should be made to.
user - a username (may be null) for authentication to the RDBMS
password - a password (may be null) for authentication to the RDBMS
minPoolSize - the minimum (and starting) number of Connections that should be held in the pool.
maxPoolSize - the maximum number of Connections that should be held in the pool.
acquireIncrement - the number of Connections that should be acquired at a time when the pool runs out of Connections
maxIdleTime - the maximum number of seconds a Connection should be allowed to remain idle before it is expired from the pool. A value of 0 means Connections never expire.
maxStatements - the maximum number of PreparedStatements that should be cached by this pool. A value of 0 means that Statement caching should be disabled.

create

public static DataSource create(String jdbcUrl,
                                String user,
                                String password,
                                int minPoolSize,
                                int maxPoolSize,
                                int acquireIncrement,
                                int maxIdleTime,
                                int maxStatements,
                                String factoryLocation)
            throws SQLException
Creates a pool-backed DataSource.

Warning: If you use this method, you must make sure a JDBC driver capable of resolving jdbcUrl has been preloaded!

Parameters:
jdbcUrl - the jdbcUrl of the RDBMS that Connections should be made to.
user - a username (may be null) for authentication to the RDBMS
password - a password (may be null) for authentication to the RDBMS
minPoolSize - the minimum (and starting) number of Connections that should be held in the pool.
maxPoolSize - the maximum number of Connections that should be held in the pool.
acquireIncrement - the number of Connections that should be acquired at a time when the pool runs out of Connections
maxIdleTime - the maximum number of seconds a Connection should be allowed to remain idle before it is expired from the pool. A value of 0 means Connections never expire.
maxStatements - the maximum number of PreparedStatements that should be cached by this pool. A value of 0 means that Statement caching should be disabled.
factoryLocation - a codebase url where JNDI clients can find the c3p0 libraries. Use null if clients will be expected to have the libraries available locally. Used only if the JNDI service prefers References to Serialized Objects when Objects are bound.

createReferenceable

public static DataSource createReferenceable(DataSource unpooledDataSource,
                                             String factoryLocation)
            throws SQLException

Deprecated. all implementations are now both Referenceable and Serializable. use create()

Creates a pool-backed DataSource that uses default pool parameters and implements Referenceable for binding to JNDI name services. For this to work, unpooledDataSource must also implement Referenceable.
Parameters:
unpooledDataSource - an unpooledDataSource to use as the primary source for connections.
factoryLocation - a codebase url where JNDI clients can find the c3p0 libraries. Use null if clients will be expected to have the libraries available locally.

createReferenceable

public static DataSource createReferenceable(DataSource unpooledDataSource,
                                             int minPoolSize,
                                             int maxPoolSize,
                                             int acquireIncrement,
                                             int maxIdleTime,
                                             int maxStatements,
                                             String factoryLocation)
            throws SQLException

Deprecated. all implementations are now both Referenceable and Serializable. use create()

Creates a pool-backed DataSource that implements Referenceable for binding to JNDI name services. For this to work, unpooledDataSource must also implement Referenceable.
Parameters:
unpooledDataSource - an unpooledDataSource to use as the primary source for connections.
minPoolSize - the minimum (and starting) number of Connections that should be held in the pool.
maxPoolSize - the maximum number of Connections that should be held in the pool.
acquireIncrement - the number of Connections that should be acquired at a time when the pool runs out of Connections
maxIdleTime - the maximum number of seconds a Connection should be allowed to remain idle before it is expired from the pool. A value of 0 means Connections never expire.
maxStatements - the maximum number of PreparedStatements that should be cached by this pool. A value of 0 means that Statement caching should be disabled.
factoryLocation - a codebase url where JNDI clients can find the c3p0 libraries. Use null if clients will be expected to have the libraries available locally.

createReferenceable

public static DataSource createReferenceable(String jdbcDriverClass,
                                             String jdbcUrl,
                                             String user,
                                             String password,
                                             String factoryLocation)
            throws SQLException

Deprecated. all implementations are now both Referenceable and Serializable. use create()

Creates a pool-backed DataSource that implements Referenceable and uses default pooling parameters.
Parameters:
jdbcDriverClass - a jdbc driver class that can resolve jdbcUrl.
jdbcUrl - the jdbcUrl of the RDBMS that Connections should be made to.
user - a username (may be null) for authentication to the RDBMS
password - a password (may be null) for authentication to the RDBMS
factoryLocation - a codebase url where JNDI clients can find the c3p0 libraries. Use null if clients will be expected to have the libraries available locally.

createReferenceable

public static DataSource createReferenceable(String jdbcDriverClass,
                                             String jdbcUrl,
                                             String user,
                                             String password,
                                             int minPoolSize,
                                             int maxPoolSize,
                                             int acquireIncrement,
                                             int maxIdleTime,
                                             int maxStatements,
                                             String factoryLocation)
            throws SQLException

Deprecated. all implementations are now both Referenceable and Serializable. use create()

Creates a pool-backed DataSource that implements Referenceable.
Parameters:
jdbcDriverClass - a jdbc driver class that can resolve jdbcUrl.
jdbcUrl - the jdbcUrl of the RDBMS that Connections should be made to.
user - a username (may be null) for authentication to the RDBMS
password - a password (may be null) for authentication to the RDBMS
minPoolSize - the minimum (and starting) number of Connections that should be held in the pool.
maxPoolSize - the maximum number of Connections that should be held in the pool.
acquireIncrement - the number of Connections that should be acquired at a time when the pool runs out of Connections
maxIdleTime - the maximum number of seconds a Connection should be allowed to remain idle before it is expired from the pool. A value of 0 means Connections never expire.
maxStatements - the maximum number of PreparedStatements that should be cached by this pool. A value of 0 means that Statement caching should be disabled.
factoryLocation - a codebase url where JNDI clients can find the c3p0 libraries. Use null if clients will be expected to have the libraries available locally.

createSerializable

public static DataSource createSerializable(DataSource unpooledDataSource)
            throws SQLException

Deprecated. all implementations are now both Referenceable and Serializable. use create()

Creates a pool-backed DataSource that uses default pool parameters and implements Serializable for binding to JNDI name services. For this to work, unpooledDataSource must also implement Serializable.
Parameters:
unpooledDataSource - an unpooledDataSource to use as the primary source for connections.

createSerializable

public static DataSource createSerializable(DataSource unpooledDataSource,
                                            int minPoolSize,
                                            int maxPoolSize,
                                            int acquireIncrement,
                                            int maxIdleTime,
                                            int maxStatements)
            throws SQLException

Deprecated. all implementations are now both Referenceable and Serializable. use create()

Creates a pool-backed DataSource that implements Serializable for binding to JNDI name services. For this to work, unpooledDataSource must also implement Serializable.
Parameters:
unpooledDataSource - an unpooledDataSource to use as the primary source for connections.
minPoolSize - the minimum (and starting) number of Connections that should be held in the pool.
maxPoolSize - the maximum number of Connections that should be held in the pool.
acquireIncrement - the number of Connections that should be acquired at a time when the pool runs out of Connections
maxIdleTime - the maximum number of seconds a Connection should be allowed to remain idle before it is expired from the pool. A value of 0 means Connections never expire.
maxStatements - the maximum number of PreparedStatements that should be cached by this pool. A value of 0 means that Statement caching should be disabled.

createSerializable

public static DataSource createSerializable(String jdbcDriverClass,
                                            String jdbcUrl,
                                            String user,
                                            String password)
            throws SQLException

Deprecated. all implementations are now both Referenceable and Serializable. use create()

Creates a pool-backed DataSource that implements Serializable and uses default pooling parameters.
Parameters:
jdbcDriverClass - a jdbc driver class that can resolve jdbcUrl.
jdbcUrl - the jdbcUrl of the RDBMS that Connections should be made to.
user - a username (may be null) for authentication to the RDBMS
password - a password (may be null) for authentication to the RDBMS

createSerializable

public static DataSource createSerializable(String jdbcDriverClass,
                                            String jdbcUrl,
                                            String user,
                                            String password,
                                            int minPoolSize,
                                            int maxPoolSize,
                                            int acquireIncrement,
                                            int maxIdleTime,
                                            int maxStatements)
            throws SQLException

Deprecated. all implementations are now both Referenceable and Serializable. use create()

Creates a pool-backed DataSource that implements Serializable.
Parameters:
jdbcDriverClass - a jdbc driver class that can resolve jdbcUrl.
jdbcUrl - the jdbcUrl of the RDBMS that Connections should be made to.
user - a username (may be null) for authentication to the RDBMS
password - a password (may be null) for authentication to the RDBMS
minPoolSize - the minimum (and starting) number of Connections that should be held in the pool.
maxPoolSize - the maximum number of Connections that should be held in the pool.
acquireIncrement - the number of Connections that should be acquired at a time when the pool runs out of Connections
maxIdleTime - the maximum number of seconds a Connection should be allowed to remain idle before it is expired from the pool. A value of 0 means Connections never expire.
maxStatements - the maximum number of PreparedStatements that should be cached by this pool. A value of 0 means that Statement caching should be disabled.