public class PoolableConnectionFactory extends Object implements PoolableObjectFactory<PoolableConnection>
PoolableObjectFactory that creates
PoolableConnections.| Modifier and Type | Field and Description |
|---|---|
protected AbandonedConfig |
_config
Configuration for removing abandoned connections.
|
protected Collection<String> |
_connectionInitSqls |
protected ConnectionFactory |
_connFactory |
protected boolean |
_defaultAutoCommit |
protected String |
_defaultCatalog |
protected Boolean |
_defaultReadOnly |
protected int |
_defaultTransactionIsolation |
protected ObjectPool<PoolableConnection> |
_pool |
protected KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> |
_stmtPoolFactory |
protected String |
_validationQuery |
protected int |
_validationQueryTimeout |
| Constructor and Description |
|---|
PoolableConnectionFactory(ConnectionFactory connFactory,
ObjectPool<PoolableConnection> pool,
KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
String validationQuery,
boolean defaultReadOnly,
boolean defaultAutoCommit)
Create a new
PoolableConnectionFactory. |
PoolableConnectionFactory(ConnectionFactory connFactory,
ObjectPool<PoolableConnection> pool,
KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
String validationQuery,
boolean defaultReadOnly,
boolean defaultAutoCommit,
AbandonedConfig config)
Create a new
PoolableConnectionFactory. |
PoolableConnectionFactory(ConnectionFactory connFactory,
ObjectPool<PoolableConnection> pool,
KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
String validationQuery,
boolean defaultReadOnly,
boolean defaultAutoCommit,
int defaultTransactionIsolation)
Create a new
PoolableConnectionFactory. |
PoolableConnectionFactory(ConnectionFactory connFactory,
ObjectPool<PoolableConnection> pool,
KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
String validationQuery,
boolean defaultReadOnly,
boolean defaultAutoCommit,
int defaultTransactionIsolation,
AbandonedConfig config)
Create a new
PoolableConnectionFactory. |
PoolableConnectionFactory(ConnectionFactory connFactory,
ObjectPool<PoolableConnection> pool,
KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
String validationQuery,
boolean defaultReadOnly,
boolean defaultAutoCommit,
int defaultTransactionIsolation,
String defaultCatalog,
AbandonedConfig config)
Create a new
PoolableConnectionFactory. |
PoolableConnectionFactory(ConnectionFactory connFactory,
ObjectPool<PoolableConnection> pool,
KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
String validationQuery,
Boolean defaultReadOnly,
boolean defaultAutoCommit,
int defaultTransactionIsolation,
String defaultCatalog,
AbandonedConfig config)
Create a new
PoolableConnectionFactory. |
PoolableConnectionFactory(ConnectionFactory connFactory,
ObjectPool<PoolableConnection> pool,
KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
String validationQuery,
Collection<String> connectionInitSqls,
boolean defaultReadOnly,
boolean defaultAutoCommit)
Create a new
PoolableConnectionFactory. |
PoolableConnectionFactory(ConnectionFactory connFactory,
ObjectPool<PoolableConnection> pool,
KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
String validationQuery,
Collection<String> connectionInitSqls,
boolean defaultReadOnly,
boolean defaultAutoCommit,
int defaultTransactionIsolation)
Create a new
PoolableConnectionFactory. |
PoolableConnectionFactory(ConnectionFactory connFactory,
ObjectPool<PoolableConnection> pool,
KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
String validationQuery,
Collection<String> connectionInitSqls,
Boolean defaultReadOnly,
boolean defaultAutoCommit,
int defaultTransactionIsolation,
String defaultCatalog,
AbandonedConfig config)
Create a new
PoolableConnectionFactory. |
PoolableConnectionFactory(ConnectionFactory connFactory,
ObjectPool<PoolableConnection> pool,
KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
String validationQuery,
int validationQueryTimeout,
boolean defaultReadOnly,
boolean defaultAutoCommit)
Create a new
PoolableConnectionFactory. |
PoolableConnectionFactory(ConnectionFactory connFactory,
ObjectPool<PoolableConnection> pool,
KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
String validationQuery,
int validationQueryTimeout,
boolean defaultReadOnly,
boolean defaultAutoCommit,
int defaultTransactionIsolation)
Create a new
PoolableConnectionFactory. |
PoolableConnectionFactory(ConnectionFactory connFactory,
ObjectPool<PoolableConnection> pool,
KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
String validationQuery,
int validationQueryTimeout,
Boolean defaultReadOnly,
boolean defaultAutoCommit,
int defaultTransactionIsolation,
String defaultCatalog,
AbandonedConfig config)
Create a new
PoolableConnectionFactory. |
PoolableConnectionFactory(ConnectionFactory connFactory,
ObjectPool<PoolableConnection> pool,
KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
String validationQuery,
int validationQueryTimeout,
Collection<String> connectionInitSqls,
boolean defaultReadOnly,
boolean defaultAutoCommit)
Create a new
PoolableConnectionFactory. |
PoolableConnectionFactory(ConnectionFactory connFactory,
ObjectPool<PoolableConnection> pool,
KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
String validationQuery,
int validationQueryTimeout,
Collection<String> connectionInitSqls,
boolean defaultReadOnly,
boolean defaultAutoCommit,
int defaultTransactionIsolation)
Create a new
PoolableConnectionFactory. |
PoolableConnectionFactory(ConnectionFactory connFactory,
ObjectPool<PoolableConnection> pool,
KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
String validationQuery,
int validationQueryTimeout,
Collection<String> connectionInitSqls,
Boolean defaultReadOnly,
boolean defaultAutoCommit,
int defaultTransactionIsolation,
String defaultCatalog,
AbandonedConfig config)
Create a new
PoolableConnectionFactory. |
| Modifier and Type | Method and Description |
|---|---|
void |
activateObject(PoolableConnection conn)
Reinitialize an instance to be returned by the pool.
|
void |
destroyObject(PoolableConnection obj)
Destroys an instance no longer needed by the pool.
|
ObjectPool<PoolableConnection> |
getPool()
Returns the
ObjectPool in which Connections are pooled. |
protected void |
initializeConnection(Connection conn) |
PoolableConnection |
makeObject()
Creates an instance that can be served by the pool.
|
void |
passivateObject(PoolableConnection conn)
Uninitialize an instance to be returned to the idle object pool.
|
void |
setConnectionFactory(ConnectionFactory connFactory)
Sets the
ConnectionFactory from which to obtain base Connections. |
void |
setConnectionInitSql(Collection<String> connectionInitSqls)
Sets the SQL statements I use to initialize newly created
Connections. |
void |
setDefaultAutoCommit(boolean defaultAutoCommit)
Sets the default "auto commit" setting for borrowed
Connections |
void |
setDefaultCatalog(String defaultCatalog)
Sets the default "catalog" setting for borrowed
Connections |
void |
setDefaultReadOnly(boolean defaultReadOnly)
Sets the default "read only" setting for borrowed
Connections |
void |
setDefaultTransactionIsolation(int defaultTransactionIsolation)
Sets the default "Transaction Isolation" setting for borrowed
Connections |
void |
setPool(ObjectPool<PoolableConnection> pool)
Sets the
ObjectPool in which to pool Connections. |
void |
setStatementPoolFactory(KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory)
|
void |
setValidationQuery(String validationQuery)
Sets the query I use to
validate Connections. |
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(Connection conn) |
boolean |
validateObject(PoolableConnection obj)
Ensures that the instance is safe to be returned by the pool.
|
protected volatile ConnectionFactory _connFactory
protected volatile String _validationQuery
protected volatile int _validationQueryTimeout
protected Collection<String> _connectionInitSqls
protected volatile ObjectPool<PoolableConnection> _pool
protected volatile KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> _stmtPoolFactory
protected Boolean _defaultReadOnly
protected boolean _defaultAutoCommit
protected int _defaultTransactionIsolation
protected String _defaultCatalog
protected AbandonedConfig _config
public PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit)
PoolableConnectionFactory.connFactory - the ConnectionFactory from which to obtain base Connectionspool - the ObjectPool in which to pool those ConnectionsstmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement poolingvalidationQuery - a query to use to validate Connections. Should return at least one row. Using null turns off validation.defaultReadOnly - the default "read only" setting for borrowed ConnectionsdefaultAutoCommit - the default "auto commit" setting for returned Connectionspublic PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, Collection<String> connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit)
PoolableConnectionFactory.connFactory - the ConnectionFactory from which to obtain base Connectionspool - the ObjectPool in which to pool those ConnectionsstmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement poolingvalidationQuery - a query to use to validate Connections. Should return at least one row. Using null turns off validation.connectionInitSqls - a Collection of SQL statements to initialize Connections. Using null turns off initialization.defaultReadOnly - the default "read only" setting for borrowed ConnectionsdefaultAutoCommit - the default "auto commit" setting for returned Connectionspublic PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, int validationQueryTimeout, boolean defaultReadOnly, boolean defaultAutoCommit)
PoolableConnectionFactory.connFactory - the ConnectionFactory from which to obtain base Connectionspool - the ObjectPool in which to pool those ConnectionsstmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement poolingvalidationQuery - a query to use to validate Connections. 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 borrowed ConnectionsdefaultAutoCommit - the default "auto commit" setting for returned Connectionspublic PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, int validationQueryTimeout, Collection<String> connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit)
PoolableConnectionFactory.connFactory - the ConnectionFactory from which to obtain base Connectionspool - the ObjectPool in which to pool those ConnectionsstmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement poolingvalidationQuery - a query to use to validate Connections. 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 initialize Connections. Using null turns off initialization.defaultReadOnly - the default "read only" setting for borrowed ConnectionsdefaultAutoCommit - the default "auto commit" setting for returned Connectionspublic PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)
PoolableConnectionFactory.connFactory - the ConnectionFactory from which to obtain base Connectionspool - the ObjectPool in which to pool those ConnectionsstmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement poolingvalidationQuery - a query to use to validate Connections. Should return at least one row. Using null turns off validation.defaultReadOnly - the default "read only" setting for borrowed ConnectionsdefaultAutoCommit - the default "auto commit" setting for returned ConnectionsdefaultTransactionIsolation - the default "Transaction Isolation" setting for returned Connectionspublic PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, Collection<String> connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)
PoolableConnectionFactory.connFactory - the ConnectionFactory from which to obtain base Connectionspool - the ObjectPool in which to pool those ConnectionsstmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement poolingvalidationQuery - a query to use to validate Connections. Should return at least one row. Using null turns off validation.connectionInitSqls - a Collection of SQL statement to initialize Connections. Using null turns off initialization.defaultReadOnly - the default "read only" setting for borrowed ConnectionsdefaultAutoCommit - the default "auto commit" setting for returned ConnectionsdefaultTransactionIsolation - the default "Transaction Isolation" setting for returned Connectionspublic PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, int validationQueryTimeout, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)
PoolableConnectionFactory.connFactory - the ConnectionFactory from which to obtain base Connectionspool - the ObjectPool in which to pool those ConnectionsstmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement poolingvalidationQuery - a query to use to validate Connections. 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 borrowed ConnectionsdefaultAutoCommit - the default "auto commit" setting for returned ConnectionsdefaultTransactionIsolation - the default "Transaction Isolation" setting for returned Connectionspublic PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, int validationQueryTimeout, Collection<String> connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)
PoolableConnectionFactory.connFactory - the ConnectionFactory from which to obtain base Connectionspool - the ObjectPool in which to pool those ConnectionsstmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement poolingvalidationQuery - a query to use to validate Connections. 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 initialize Connections. Using null turns off initialization.defaultReadOnly - the default "read only" setting for borrowed ConnectionsdefaultAutoCommit - the default "auto commit" setting for returned ConnectionsdefaultTransactionIsolation - the default "Transaction Isolation" setting for returned Connectionspublic PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, AbandonedConfig config)
PoolableConnectionFactory.connFactory - the ConnectionFactory from which to obtain base Connectionspool - the ObjectPool in which to pool those ConnectionsstmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement poolingvalidationQuery - a query to use to validate Connections. Should return at least one row. Using null turns off validation.defaultReadOnly - the default "read only" setting for borrowed ConnectionsdefaultAutoCommit - the default "auto commit" setting for returned Connectionsconfig - the AbandonedConfig if tracing SQL objectspublic PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, AbandonedConfig config)
PoolableConnectionFactory.connFactory - the ConnectionFactory from which to obtain base Connectionspool - the ObjectPool in which to pool those ConnectionsstmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement poolingvalidationQuery - a query to use to validate Connections. Should return at least one row. Using null turns off validation.defaultReadOnly - the default "read only" setting for borrowed ConnectionsdefaultAutoCommit - the default "auto commit" setting for returned ConnectionsdefaultTransactionIsolation - the default "Transaction Isolation" setting for returned Connectionsconfig - the AbandonedConfig if tracing SQL objectspublic PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, String defaultCatalog, AbandonedConfig config)
PoolableConnectionFactory.connFactory - the ConnectionFactory from which to obtain base Connectionspool - the ObjectPool in which to pool those ConnectionsstmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement poolingvalidationQuery - a query to use to validate Connections. Should return at least one row. Using null turns off validation.defaultReadOnly - the default "read only" setting for borrowed ConnectionsdefaultAutoCommit - the default "auto commit" setting for returned ConnectionsdefaultTransactionIsolation - the default "Transaction Isolation" setting for returned ConnectionsdefaultCatalog - the default "catalog" setting for returned Connectionsconfig - the AbandonedConfig if tracing SQL objectspublic PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, String defaultCatalog, AbandonedConfig config)
PoolableConnectionFactory.connFactory - the ConnectionFactory from which to obtain base Connectionspool - the ObjectPool in which to pool those ConnectionsstmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement poolingvalidationQuery - a query to use to validate Connections. Should return at least one row. Using null turns off validation.defaultReadOnly - the default "read only" setting for borrowed ConnectionsdefaultAutoCommit - the default "auto commit" setting for returned ConnectionsdefaultTransactionIsolation - the default "Transaction Isolation" setting for returned ConnectionsdefaultCatalog - the default "catalog" setting for returned Connectionsconfig - the AbandonedConfig if tracing SQL objectspublic PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, Collection<String> connectionInitSqls, Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, String defaultCatalog, AbandonedConfig config)
PoolableConnectionFactory.connFactory - the ConnectionFactory from which to obtain base Connectionspool - the ObjectPool in which to pool those ConnectionsstmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement poolingvalidationQuery - a query to use to validate Connections. Should return at least one row. Using null turns off validation.connectionInitSqls - a Collection of SQL statements to initialize Connections. Using null turns off initialization.defaultReadOnly - the default "read only" setting for borrowed ConnectionsdefaultAutoCommit - the default "auto commit" setting for returned ConnectionsdefaultTransactionIsolation - the default "Transaction Isolation" setting for returned ConnectionsdefaultCatalog - the default "catalog" setting for returned Connectionsconfig - the AbandonedConfig if tracing SQL objectspublic PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, int validationQueryTimeout, Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, String defaultCatalog, AbandonedConfig config)
PoolableConnectionFactory.connFactory - the ConnectionFactory from which to obtain base Connectionspool - the ObjectPool in which to pool those ConnectionsstmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement poolingvalidationQuery - a query to use to validate Connections. 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 borrowed ConnectionsdefaultAutoCommit - the default "auto commit" setting for returned ConnectionsdefaultTransactionIsolation - the default "Transaction Isolation" setting for returned ConnectionsdefaultCatalog - the default "catalog" setting for returned Connectionsconfig - the AbandonedConfig if tracing SQL objectspublic PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, int validationQueryTimeout, Collection<String> connectionInitSqls, Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, String defaultCatalog, AbandonedConfig config)
PoolableConnectionFactory.connFactory - the ConnectionFactory from which to obtain base Connectionspool - the ObjectPool in which to pool those ConnectionsstmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement poolingvalidationQuery - a query to use to validate Connections. 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 initialize Connections. Using null turns off initialization.defaultReadOnly - the default "read only" setting for borrowed ConnectionsdefaultAutoCommit - the default "auto commit" setting for returned ConnectionsdefaultTransactionIsolation - the default "Transaction Isolation" setting for returned ConnectionsdefaultCatalog - the default "catalog" setting for returned Connectionsconfig - the AbandonedConfig if tracing SQL objectspublic void setConnectionFactory(ConnectionFactory connFactory)
ConnectionFactory from which to obtain base Connections.connFactory - the ConnectionFactory from which to obtain base Connectionspublic void setValidationQuery(String validationQuery)
validate Connections.
Should return at least one row.
Using null turns off validation.validationQuery - a query to use to validate Connections.public void setValidationQueryTimeout(int timeout)
timeout - new validation query timeout value in secondspublic void setConnectionInitSql(Collection<String> connectionInitSqls)
Connections.
Using null turns off connection initialization.connectionInitSqls - SQL statement to initialize Connections.public void setPool(ObjectPool<PoolableConnection> pool)
ObjectPool in which to pool Connections.pool - the ObjectPool in which to pool those Connectionspublic ObjectPool<PoolableConnection> getPool()
ObjectPool in which Connections are pooled.public void setStatementPoolFactory(KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory)
KeyedObjectPoolFactory I use to create KeyedObjectPools
for pooling PreparedStatements.
Set to null to disable PreparedStatement pooling.stmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatementspublic void setDefaultReadOnly(boolean defaultReadOnly)
ConnectionsdefaultReadOnly - the default "read only" setting for borrowed Connectionspublic void setDefaultAutoCommit(boolean defaultAutoCommit)
ConnectionsdefaultAutoCommit - the default "auto commit" setting for borrowed Connectionspublic void setDefaultTransactionIsolation(int defaultTransactionIsolation)
ConnectionsdefaultTransactionIsolation - the default "Transaction Isolation" setting for returned Connectionspublic void setDefaultCatalog(String defaultCatalog)
ConnectionsdefaultCatalog - the default "catalog" setting for borrowed Connectionspublic PoolableConnection makeObject() throws Exception
PoolableObjectFactoryactivated. They will not be
activated before being served by the pool.makeObject in interface PoolableObjectFactory<PoolableConnection>Exception - if there is a problem creating a new instance,
this will be propagated to the code requesting an object.protected void initializeConnection(Connection conn) throws SQLException
SQLExceptionpublic void destroyObject(PoolableConnection obj) throws Exception
PoolableObjectFactory
It is important for implementations of this method to be aware
that there is no guarantee about what state obj
will be in and the implementation should be prepared to handle
unexpected errors.
Also, an implementation must take in to consideration that instances lost to the garbage collector may never be destroyed.
destroyObject in interface PoolableObjectFactory<PoolableConnection>obj - the instance to be destroyedException - should be avoided as it may be swallowed by
the pool implementation.PoolableObjectFactory.validateObject(T),
ObjectPool.invalidateObject(T)public boolean validateObject(PoolableConnection obj)
PoolableObjectFactoryfalse if obj should be destroyed.validateObject in interface PoolableObjectFactory<PoolableConnection>obj - the instance to be validatedfalse if obj is not valid and should
be dropped from the pool, true otherwise.public void validateConnection(Connection conn) throws SQLException
SQLExceptionpublic void passivateObject(PoolableConnection conn) throws Exception
PoolableObjectFactorypassivateObject in interface PoolableObjectFactory<PoolableConnection>conn - the instance to be passivatedException - if there is a problem passivating obj,
this exception may be swallowed by the pool.PoolableObjectFactory.destroyObject(T)public void activateObject(PoolableConnection conn) throws Exception
PoolableObjectFactoryactivateObject in interface PoolableObjectFactory<PoolableConnection>conn - the instance to be activatedException - if there is a problem activating obj,
this exception may be swallowed by the pool.PoolableObjectFactory.destroyObject(T)Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.