Package org.apache.commons.dbcp
Class PoolableConnectionFactory
- java.lang.Object
-
- org.apache.commons.dbcp.PoolableConnectionFactory
-
- All Implemented Interfaces:
org.apache.commons.pool.PoolableObjectFactory
- Direct Known Subclasses:
PoolableManagedConnectionFactory
public class PoolableConnectionFactory extends java.lang.Object implements org.apache.commons.pool.PoolableObjectFactory
APoolableObjectFactory
that createsPoolableConnection
s.- Version:
- $Revision: 883393 $ $Date: 2009-11-23 11:18:35 -0500 (Mon, 23 Nov 2009) $
- Author:
- Rodney Waldhoff, Glenn L. Nielsen, James House, Dirk Verbeeck
-
-
Field Summary
Fields Modifier and Type Field Description protected AbandonedConfig
_config
Configuration for removing abandoned connections.protected java.util.Collection
_connectionInitSqls
protected ConnectionFactory
_connFactory
protected boolean
_defaultAutoCommit
protected java.lang.String
_defaultCatalog
protected java.lang.Boolean
_defaultReadOnly
protected int
_defaultTransactionIsolation
protected org.apache.commons.pool.ObjectPool
_pool
protected org.apache.commons.pool.KeyedObjectPoolFactory
_stmtPoolFactory
protected java.lang.String
_validationQuery
protected int
_validationQueryTimeout
-
Constructor Summary
Constructors Constructor Description PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit)
Create a new PoolableConnectionFactory.PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)
Create a new PoolableConnectionFactory.PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, java.lang.String defaultCatalog, AbandonedConfig config)
Create a new PoolableConnectionFactory.PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, AbandonedConfig config)
Create a new PoolableConnectionFactory.PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, AbandonedConfig config)
Create a new PoolableConnectionFactory.PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, int validationQueryTimeout, boolean defaultReadOnly, boolean defaultAutoCommit)
Create a new PoolableConnectionFactory.PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, int validationQueryTimeout, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)
Create a new PoolableConnectionFactory.PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, int validationQueryTimeout, java.lang.Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, java.lang.String defaultCatalog, AbandonedConfig config)
Create a new PoolableConnectionFactory.PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, int validationQueryTimeout, java.util.Collection connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit)
Create a new PoolableConnectionFactory.PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, int validationQueryTimeout, java.util.Collection connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)
Create a new PoolableConnectionFactory.PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, int validationQueryTimeout, java.util.Collection connectionInitSqls, java.lang.Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, java.lang.String defaultCatalog, AbandonedConfig config)
Create a new PoolableConnectionFactory.PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, java.lang.Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, java.lang.String defaultCatalog, AbandonedConfig config)
Create a new PoolableConnectionFactory.PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, java.util.Collection connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit)
Create a new PoolableConnectionFactory.PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, java.util.Collection connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)
Create a new PoolableConnectionFactory.PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, java.util.Collection connectionInitSqls, java.lang.Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, java.lang.String defaultCatalog, AbandonedConfig config)
Create a new PoolableConnectionFactory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activateObject(java.lang.Object obj)
void
destroyObject(java.lang.Object obj)
org.apache.commons.pool.ObjectPool
getPool()
Returns theObjectPool
in whichConnection
s are pooled.protected void
initializeConnection(java.sql.Connection conn)
java.lang.Object
makeObject()
void
passivateObject(java.lang.Object obj)
void
setConnectionFactory(ConnectionFactory connFactory)
Sets theConnectionFactory
from which to obtain baseConnection
s.void
setConnectionInitSql(java.util.Collection connectionInitSqls)
Sets the SQL statements I use to initialize newly createdConnection
s.void
setDefaultAutoCommit(boolean defaultAutoCommit)
Sets the default "auto commit" setting for borrowedConnection
svoid
setDefaultCatalog(java.lang.String defaultCatalog)
Sets the default "catalog" setting for borrowedConnection
svoid
setDefaultReadOnly(boolean defaultReadOnly)
Sets the default "read only" setting for borrowedConnection
svoid
setDefaultTransactionIsolation(int defaultTransactionIsolation)
Sets the default "Transaction Isolation" setting for borrowedConnection
svoid
setPool(org.apache.commons.pool.ObjectPool pool)
Sets theObjectPool
in which to poolConnection
s.void
setStatementPoolFactory(org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory)
Sets theKeyedObjectPoolFactory
I use to createKeyedObjectPool
s for poolingPreparedStatement
s.void
setValidationQuery(java.lang.String validationQuery)
Sets the query I use tovalidate
Connection
s.void
setValidationQueryTimeout(int timeout)
Sets the validation query timeout, the amount of time, in seconds, that connection validation will wait for a response from the database when executing a validation query.void
validateConnection(java.sql.Connection conn)
boolean
validateObject(java.lang.Object obj)
-
-
-
Field Detail
-
_connFactory
protected volatile ConnectionFactory _connFactory
-
_validationQuery
protected volatile java.lang.String _validationQuery
-
_validationQueryTimeout
protected volatile int _validationQueryTimeout
-
_connectionInitSqls
protected java.util.Collection _connectionInitSqls
-
_pool
protected volatile org.apache.commons.pool.ObjectPool _pool
-
_stmtPoolFactory
protected volatile org.apache.commons.pool.KeyedObjectPoolFactory _stmtPoolFactory
-
_defaultReadOnly
protected java.lang.Boolean _defaultReadOnly
-
_defaultAutoCommit
protected boolean _defaultAutoCommit
-
_defaultTransactionIsolation
protected int _defaultTransactionIsolation
-
_defaultCatalog
protected java.lang.String _defaultCatalog
-
_config
protected AbandonedConfig _config
Configuration for removing abandoned connections.
-
-
Constructor Detail
-
PoolableConnectionFactory
public PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit)
Create a new PoolableConnectionFactory.- Parameters:
connFactory
- theConnectionFactory
from which to obtain baseConnection
spool
- theObjectPool
in which to pool thoseConnection
sstmtPoolFactory
- theKeyedObjectPoolFactory
to use to createKeyedObjectPool
s for poolingPreparedStatement
s, or null to disablePreparedStatement
poolingvalidationQuery
- a query to use tovalidate
Connection
s. Should return at least one row. Using null turns off validation.defaultReadOnly
- the default "read only" setting for borrowedConnection
sdefaultAutoCommit
- the default "auto commit" setting for returnedConnection
s
-
PoolableConnectionFactory
public PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, java.util.Collection connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit)
Create a new PoolableConnectionFactory.- Parameters:
connFactory
- theConnectionFactory
from which to obtain baseConnection
spool
- theObjectPool
in which to pool thoseConnection
sstmtPoolFactory
- theKeyedObjectPoolFactory
to use to createKeyedObjectPool
s for poolingPreparedStatement
s, or null to disablePreparedStatement
poolingvalidationQuery
- a query to use tovalidate
Connection
s. Should return at least one row. Using null turns off validation.connectionInitSqls
- a Collection of SQL statements to initializeConnection
s. Using null turns off initialization.defaultReadOnly
- the default "read only" setting for borrowedConnection
sdefaultAutoCommit
- the default "auto commit" setting for returnedConnection
s- Since:
- 1.3
-
PoolableConnectionFactory
public PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, int validationQueryTimeout, boolean defaultReadOnly, boolean defaultAutoCommit)
Create a new PoolableConnectionFactory.- Parameters:
connFactory
- theConnectionFactory
from which to obtain baseConnection
spool
- theObjectPool
in which to pool thoseConnection
sstmtPoolFactory
- theKeyedObjectPoolFactory
to use to createKeyedObjectPool
s for poolingPreparedStatement
s, or null to disablePreparedStatement
poolingvalidationQuery
- a query to use tovalidate
Connection
s. Should return at least one row. Using null turns off validation.validationQueryTimeout
- the number of seconds that validation queries will wait for database response before failing. Use a value less than or equal to 0 for no timeout.defaultReadOnly
- the default "read only" setting for borrowedConnection
sdefaultAutoCommit
- the default "auto commit" setting for returnedConnection
s- Since:
- 1.3
-
PoolableConnectionFactory
public PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, int validationQueryTimeout, java.util.Collection connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit)
Create a new PoolableConnectionFactory.- Parameters:
connFactory
- theConnectionFactory
from which to obtain baseConnection
spool
- theObjectPool
in which to pool thoseConnection
sstmtPoolFactory
- theKeyedObjectPoolFactory
to use to createKeyedObjectPool
s for poolingPreparedStatement
s, or null to disablePreparedStatement
poolingvalidationQuery
- a query to use tovalidate
Connection
s. Should return at least one row. Using null turns off validation.validationQueryTimeout
- the number of seconds that validation queries will wait for database response before failing. Use a value less than or equal to 0 for no timeout.connectionInitSqls
- a Collection of SQL statements to initializeConnection
s. Using null turns off initialization.defaultReadOnly
- the default "read only" setting for borrowedConnection
sdefaultAutoCommit
- the default "auto commit" setting for returnedConnection
s- Since:
- 1.3
-
PoolableConnectionFactory
public PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)
Create a new PoolableConnectionFactory.- Parameters:
connFactory
- theConnectionFactory
from which to obtain baseConnection
spool
- theObjectPool
in which to pool thoseConnection
sstmtPoolFactory
- theKeyedObjectPoolFactory
to use to createKeyedObjectPool
s for poolingPreparedStatement
s, or null to disablePreparedStatement
poolingvalidationQuery
- a query to use tovalidate
Connection
s. Should return at least one row. Using null turns off validation.defaultReadOnly
- the default "read only" setting for borrowedConnection
sdefaultAutoCommit
- the default "auto commit" setting for returnedConnection
sdefaultTransactionIsolation
- the default "Transaction Isolation" setting for returnedConnection
s
-
PoolableConnectionFactory
public PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, java.util.Collection connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)
Create a new PoolableConnectionFactory.- Parameters:
connFactory
- theConnectionFactory
from which to obtain baseConnection
spool
- theObjectPool
in which to pool thoseConnection
sstmtPoolFactory
- theKeyedObjectPoolFactory
to use to createKeyedObjectPool
s for poolingPreparedStatement
s, or null to disablePreparedStatement
poolingvalidationQuery
- a query to use tovalidate
Connection
s. Should return at least one row. Using null turns off validation.connectionInitSqls
- a Collection of SQL statement to initializeConnection
s. Using null turns off initialization.defaultReadOnly
- the default "read only" setting for borrowedConnection
sdefaultAutoCommit
- the default "auto commit" setting for returnedConnection
sdefaultTransactionIsolation
- the default "Transaction Isolation" setting for returnedConnection
s- Since:
- 1.3
-
PoolableConnectionFactory
public PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, int validationQueryTimeout, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)
Create a new PoolableConnectionFactory.- Parameters:
connFactory
- theConnectionFactory
from which to obtain baseConnection
spool
- theObjectPool
in which to pool thoseConnection
sstmtPoolFactory
- theKeyedObjectPoolFactory
to use to createKeyedObjectPool
s for poolingPreparedStatement
s, or null to disablePreparedStatement
poolingvalidationQuery
- a query to use tovalidate
Connection
s. Should return at least one row. Using null turns off validation.validationQueryTimeout
- the number of seconds that validation queries will wait for database response before failing. Use a value less than or equal to 0 for no timeout.defaultReadOnly
- the default "read only" setting for borrowedConnection
sdefaultAutoCommit
- the default "auto commit" setting for returnedConnection
sdefaultTransactionIsolation
- the default "Transaction Isolation" setting for returnedConnection
s- Since:
- 1.3
-
PoolableConnectionFactory
public PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, int validationQueryTimeout, java.util.Collection connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)
Create a new PoolableConnectionFactory.- Parameters:
connFactory
- theConnectionFactory
from which to obtain baseConnection
spool
- theObjectPool
in which to pool thoseConnection
sstmtPoolFactory
- theKeyedObjectPoolFactory
to use to createKeyedObjectPool
s for poolingPreparedStatement
s, or null to disablePreparedStatement
poolingvalidationQuery
- a query to use tovalidate
Connection
s. Should return at least one row. Using null turns off validation.validationQueryTimeout
- the number of seconds that validation queries will wait for database response before failing. Use a value less than or equal to 0 for no timeout.connectionInitSqls
- a Collection of SQL statement to initializeConnection
s. Using null turns off initialization.defaultReadOnly
- the default "read only" setting for borrowedConnection
sdefaultAutoCommit
- the default "auto commit" setting for returnedConnection
sdefaultTransactionIsolation
- the default "Transaction Isolation" setting for returnedConnection
s- Since:
- 1.3
-
PoolableConnectionFactory
public PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, AbandonedConfig config)
Create a new PoolableConnectionFactory.- Parameters:
connFactory
- theConnectionFactory
from which to obtain baseConnection
spool
- theObjectPool
in which to pool thoseConnection
sstmtPoolFactory
- theKeyedObjectPoolFactory
to use to createKeyedObjectPool
s for poolingPreparedStatement
s, or null to disablePreparedStatement
poolingvalidationQuery
- a query to use tovalidate
Connection
s. Should return at least one row. Using null turns off validation.defaultReadOnly
- the default "read only" setting for borrowedConnection
sdefaultAutoCommit
- the default "auto commit" setting for returnedConnection
sconfig
- the AbandonedConfig if tracing SQL objects
-
PoolableConnectionFactory
public PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, AbandonedConfig config)
Create a new PoolableConnectionFactory.- Parameters:
connFactory
- theConnectionFactory
from which to obtain baseConnection
spool
- theObjectPool
in which to pool thoseConnection
sstmtPoolFactory
- theKeyedObjectPoolFactory
to use to createKeyedObjectPool
s for poolingPreparedStatement
s, or null to disablePreparedStatement
poolingvalidationQuery
- a query to use tovalidate
Connection
s. Should return at least one row. Using null turns off validation.defaultReadOnly
- the default "read only" setting for borrowedConnection
sdefaultAutoCommit
- the default "auto commit" setting for returnedConnection
sdefaultTransactionIsolation
- the default "Transaction Isolation" setting for returnedConnection
sconfig
- the AbandonedConfig if tracing SQL objects
-
PoolableConnectionFactory
public PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, java.lang.String defaultCatalog, AbandonedConfig config)
Create a new PoolableConnectionFactory.- Parameters:
connFactory
- theConnectionFactory
from which to obtain baseConnection
spool
- theObjectPool
in which to pool thoseConnection
sstmtPoolFactory
- theKeyedObjectPoolFactory
to use to createKeyedObjectPool
s for poolingPreparedStatement
s, or null to disablePreparedStatement
poolingvalidationQuery
- a query to use tovalidate
Connection
s. Should return at least one row. Using null turns off validation.defaultReadOnly
- the default "read only" setting for borrowedConnection
sdefaultAutoCommit
- the default "auto commit" setting for returnedConnection
sdefaultTransactionIsolation
- the default "Transaction Isolation" setting for returnedConnection
sdefaultCatalog
- the default "catalog" setting for returnedConnection
sconfig
- the AbandonedConfig if tracing SQL objects
-
PoolableConnectionFactory
public PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, java.lang.Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, java.lang.String defaultCatalog, AbandonedConfig config)
Create a new PoolableConnectionFactory.- Parameters:
connFactory
- theConnectionFactory
from which to obtain baseConnection
spool
- theObjectPool
in which to pool thoseConnection
sstmtPoolFactory
- theKeyedObjectPoolFactory
to use to createKeyedObjectPool
s for poolingPreparedStatement
s, or null to disablePreparedStatement
poolingvalidationQuery
- a query to use tovalidate
Connection
s. Should return at least one row. Using null turns off validation.defaultReadOnly
- the default "read only" setting for borrowedConnection
sdefaultAutoCommit
- the default "auto commit" setting for returnedConnection
sdefaultTransactionIsolation
- the default "Transaction Isolation" setting for returnedConnection
sdefaultCatalog
- the default "catalog" setting for returnedConnection
sconfig
- the AbandonedConfig if tracing SQL objects
-
PoolableConnectionFactory
public PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, java.util.Collection connectionInitSqls, java.lang.Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, java.lang.String defaultCatalog, AbandonedConfig config)
Create a new PoolableConnectionFactory.- Parameters:
connFactory
- theConnectionFactory
from which to obtain baseConnection
spool
- theObjectPool
in which to pool thoseConnection
sstmtPoolFactory
- theKeyedObjectPoolFactory
to use to createKeyedObjectPool
s for poolingPreparedStatement
s, or null to disablePreparedStatement
poolingvalidationQuery
- a query to use tovalidate
Connection
s. Should return at least one row. Using null turns off validation.connectionInitSqls
- a Collection of SQL statements to initializeConnection
s. Using null turns off initialization.defaultReadOnly
- the default "read only" setting for borrowedConnection
sdefaultAutoCommit
- the default "auto commit" setting for returnedConnection
sdefaultTransactionIsolation
- the default "Transaction Isolation" setting for returnedConnection
sdefaultCatalog
- the default "catalog" setting for returnedConnection
sconfig
- the AbandonedConfig if tracing SQL objects- Since:
- 1.3
-
PoolableConnectionFactory
public PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, int validationQueryTimeout, java.lang.Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, java.lang.String defaultCatalog, AbandonedConfig config)
Create a new PoolableConnectionFactory.- Parameters:
connFactory
- theConnectionFactory
from which to obtain baseConnection
spool
- theObjectPool
in which to pool thoseConnection
sstmtPoolFactory
- theKeyedObjectPoolFactory
to use to createKeyedObjectPool
s for poolingPreparedStatement
s, or null to disablePreparedStatement
poolingvalidationQuery
- a query to use tovalidate
Connection
s. Should return at least one row. Using null turns off validation.validationQueryTimeout
- the number of seconds that validation queries will wait for database response before failing. Use a value less than or equal to 0 for no timeout.defaultReadOnly
- the default "read only" setting for borrowedConnection
sdefaultAutoCommit
- the default "auto commit" setting for returnedConnection
sdefaultTransactionIsolation
- the default "Transaction Isolation" setting for returnedConnection
sdefaultCatalog
- the default "catalog" setting for returnedConnection
sconfig
- the AbandonedConfig if tracing SQL objects- Since:
- 1.3
-
PoolableConnectionFactory
public PoolableConnectionFactory(ConnectionFactory connFactory, org.apache.commons.pool.ObjectPool pool, org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory, java.lang.String validationQuery, int validationQueryTimeout, java.util.Collection connectionInitSqls, java.lang.Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, java.lang.String defaultCatalog, AbandonedConfig config)
Create a new PoolableConnectionFactory.- Parameters:
connFactory
- theConnectionFactory
from which to obtain baseConnection
spool
- theObjectPool
in which to pool thoseConnection
sstmtPoolFactory
- theKeyedObjectPoolFactory
to use to createKeyedObjectPool
s for poolingPreparedStatement
s, or null to disablePreparedStatement
poolingvalidationQuery
- a query to use tovalidate
Connection
s. Should return at least one row. Using null turns off validation.validationQueryTimeout
- the number of seconds that validation queries will wait for database response before failing. Use a value less than or equal to 0 for no timeout.connectionInitSqls
- a Collection of SQL statements to initializeConnection
s. Using null turns off initialization.defaultReadOnly
- the default "read only" setting for borrowedConnection
sdefaultAutoCommit
- the default "auto commit" setting for returnedConnection
sdefaultTransactionIsolation
- the default "Transaction Isolation" setting for returnedConnection
sdefaultCatalog
- the default "catalog" setting for returnedConnection
sconfig
- the AbandonedConfig if tracing SQL objects- Since:
- 1.3
-
-
Method Detail
-
setConnectionFactory
public void setConnectionFactory(ConnectionFactory connFactory)
Sets theConnectionFactory
from which to obtain baseConnection
s.- Parameters:
connFactory
- theConnectionFactory
from which to obtain baseConnection
s
-
setValidationQuery
public void setValidationQuery(java.lang.String validationQuery)
Sets the query I use tovalidate
Connection
s. Should return at least one row. Using null turns off validation.- Parameters:
validationQuery
- a query to use tovalidate
Connection
s.
-
setValidationQueryTimeout
public void setValidationQueryTimeout(int timeout)
Sets the validation query timeout, the amount of time, in seconds, that connection validation will wait for a response from the database when executing a validation query. Use a value less than or equal to 0 for no timeout.- Parameters:
timeout
- new validation query timeout value in seconds- Since:
- 1.3
-
setConnectionInitSql
public void setConnectionInitSql(java.util.Collection connectionInitSqls)
Sets the SQL statements I use to initialize newly createdConnection
s. Using null turns off connection initialization.- Parameters:
connectionInitSqls
- SQL statement to initializeConnection
s.- Since:
- 1.3
-
setPool
public void setPool(org.apache.commons.pool.ObjectPool pool)
Sets theObjectPool
in which to poolConnection
s.- Parameters:
pool
- theObjectPool
in which to pool thoseConnection
s
-
getPool
public org.apache.commons.pool.ObjectPool getPool()
Returns theObjectPool
in whichConnection
s are pooled.- Returns:
- the connection pool
-
setStatementPoolFactory
public void setStatementPoolFactory(org.apache.commons.pool.KeyedObjectPoolFactory stmtPoolFactory)
Sets theKeyedObjectPoolFactory
I use to createKeyedObjectPool
s for poolingPreparedStatement
s. Set to null to disablePreparedStatement
pooling.- Parameters:
stmtPoolFactory
- theKeyedObjectPoolFactory
to use to createKeyedObjectPool
s for poolingPreparedStatement
s
-
setDefaultReadOnly
public void setDefaultReadOnly(boolean defaultReadOnly)
Sets the default "read only" setting for borrowedConnection
s- Parameters:
defaultReadOnly
- the default "read only" setting for borrowedConnection
s
-
setDefaultAutoCommit
public void setDefaultAutoCommit(boolean defaultAutoCommit)
Sets the default "auto commit" setting for borrowedConnection
s- Parameters:
defaultAutoCommit
- the default "auto commit" setting for borrowedConnection
s
-
setDefaultTransactionIsolation
public void setDefaultTransactionIsolation(int defaultTransactionIsolation)
Sets the default "Transaction Isolation" setting for borrowedConnection
s- Parameters:
defaultTransactionIsolation
- the default "Transaction Isolation" setting for returnedConnection
s
-
setDefaultCatalog
public void setDefaultCatalog(java.lang.String defaultCatalog)
Sets the default "catalog" setting for borrowedConnection
s- Parameters:
defaultCatalog
- the default "catalog" setting for borrowedConnection
s
-
makeObject
public java.lang.Object makeObject() throws java.lang.Exception
- Specified by:
makeObject
in interfaceorg.apache.commons.pool.PoolableObjectFactory
- Throws:
java.lang.Exception
-
initializeConnection
protected void initializeConnection(java.sql.Connection conn) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
destroyObject
public void destroyObject(java.lang.Object obj) throws java.lang.Exception
- Specified by:
destroyObject
in interfaceorg.apache.commons.pool.PoolableObjectFactory
- Throws:
java.lang.Exception
-
validateObject
public boolean validateObject(java.lang.Object obj)
- Specified by:
validateObject
in interfaceorg.apache.commons.pool.PoolableObjectFactory
-
validateConnection
public void validateConnection(java.sql.Connection conn) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
passivateObject
public void passivateObject(java.lang.Object obj) throws java.lang.Exception
- Specified by:
passivateObject
in interfaceorg.apache.commons.pool.PoolableObjectFactory
- Throws:
java.lang.Exception
-
activateObject
public void activateObject(java.lang.Object obj) throws java.lang.Exception
- Specified by:
activateObject
in interfaceorg.apache.commons.pool.PoolableObjectFactory
- Throws:
java.lang.Exception
-
-