org.datanucleus.store.rdbms.datasource.dbcp
Class PoolableConnectionFactory

java.lang.Object
  extended by org.datanucleus.store.rdbms.datasource.dbcp.PoolableConnectionFactory
All Implemented Interfaces:
PoolableObjectFactory
Direct Known Subclasses:
PoolableManagedConnectionFactory

public class PoolableConnectionFactory
extends Object
implements PoolableObjectFactory

A PoolableObjectFactory that creates PoolableConnections.

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
protected  AbandonedConfig _config
          Configuration for removing abandoned connections.
protected  Collection _connectionInitSqls
           
protected  ConnectionFactory _connFactory
           
protected  boolean _defaultAutoCommit
           
protected  String _defaultCatalog
           
protected  Boolean _defaultReadOnly
           
protected  int _defaultTransactionIsolation
           
protected  ObjectPool _pool
           
protected  KeyedObjectPoolFactory _stmtPoolFactory
           
protected  String _validationQuery
           
protected  int _validationQueryTimeout
           
 
Constructor Summary
PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit)
          Create a new PoolableConnectionFactory.
PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, AbandonedConfig config)
          Create a new PoolableConnectionFactory.
PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)
          Create a new PoolableConnectionFactory.
PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, AbandonedConfig config)
          Create a new PoolableConnectionFactory.
PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, String defaultCatalog, AbandonedConfig config)
          Create a new PoolableConnectionFactory.
PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, String defaultCatalog, AbandonedConfig config)
          Create a new PoolableConnectionFactory.
PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, Collection connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit)
          Create a new PoolableConnectionFactory.
PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, Collection connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)
          Create a new PoolableConnectionFactory.
PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, Collection connectionInitSqls, Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, String defaultCatalog, AbandonedConfig config)
          Create a new PoolableConnectionFactory.
PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, int validationQueryTimeout, boolean defaultReadOnly, boolean defaultAutoCommit)
          Create a new PoolableConnectionFactory.
PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, int validationQueryTimeout, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)
          Create a new PoolableConnectionFactory.
PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, int validationQueryTimeout, Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, String defaultCatalog, AbandonedConfig config)
          Create a new PoolableConnectionFactory.
PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, int validationQueryTimeout, Collection connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit)
          Create a new PoolableConnectionFactory.
PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, int validationQueryTimeout, Collection connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)
          Create a new PoolableConnectionFactory.
PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, int validationQueryTimeout, Collection connectionInitSqls, Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, String defaultCatalog, AbandonedConfig config)
          Create a new PoolableConnectionFactory.
 
Method Summary
 void activateObject(Object obj)
          Reinitialize an instance to be returned by the pool.
 void destroyObject(Object obj)
          Destroys an instance no longer needed by the pool.
 ObjectPool getPool()
          Returns the ObjectPool in which Connections are pooled.
protected  void initializeConnection(Connection conn)
           
 Object makeObject()
          Creates an instance that can be served by the pool.
 void passivateObject(Object obj)
          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 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 pool)
          Sets the ObjectPool in which to pool Connections.
 void setStatementPoolFactory(KeyedObjectPoolFactory stmtPoolFactory)
          Sets the KeyedObjectPoolFactory I use to create KeyedObjectPools for pooling PreparedStatements.
 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(Object obj)
          Ensures that the instance is safe to be returned by the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_connFactory

protected volatile ConnectionFactory _connFactory

_validationQuery

protected volatile String _validationQuery

_validationQueryTimeout

protected volatile int _validationQueryTimeout

_connectionInitSqls

protected Collection _connectionInitSqls

_pool

protected volatile ObjectPool _pool

_stmtPoolFactory

protected volatile KeyedObjectPoolFactory _stmtPoolFactory

_defaultReadOnly

protected Boolean _defaultReadOnly

_defaultAutoCommit

protected boolean _defaultAutoCommit

_defaultTransactionIsolation

protected int _defaultTransactionIsolation

_defaultCatalog

protected String _defaultCatalog

_config

protected AbandonedConfig _config
Configuration for removing abandoned connections.

Constructor Detail

PoolableConnectionFactory

public PoolableConnectionFactory(ConnectionFactory connFactory,
                                 ObjectPool pool,
                                 KeyedObjectPoolFactory stmtPoolFactory,
                                 String validationQuery,
                                 boolean defaultReadOnly,
                                 boolean defaultAutoCommit)
Create a new PoolableConnectionFactory.

Parameters:
connFactory - the ConnectionFactory from which to obtain base Connections
pool - the ObjectPool in which to pool those Connections
stmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement pooling
validationQuery - 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 Connections
defaultAutoCommit - the default "auto commit" setting for returned Connections

PoolableConnectionFactory

public PoolableConnectionFactory(ConnectionFactory connFactory,
                                 ObjectPool pool,
                                 KeyedObjectPoolFactory stmtPoolFactory,
                                 String validationQuery,
                                 Collection connectionInitSqls,
                                 boolean defaultReadOnly,
                                 boolean defaultAutoCommit)
Create a new PoolableConnectionFactory.

Parameters:
connFactory - the ConnectionFactory from which to obtain base Connections
pool - the ObjectPool in which to pool those Connections
stmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement pooling
validationQuery - 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 Connections
defaultAutoCommit - the default "auto commit" setting for returned Connections
Since:
1.3

PoolableConnectionFactory

public PoolableConnectionFactory(ConnectionFactory connFactory,
                                 ObjectPool pool,
                                 KeyedObjectPoolFactory stmtPoolFactory,
                                 String validationQuery,
                                 int validationQueryTimeout,
                                 boolean defaultReadOnly,
                                 boolean defaultAutoCommit)
Create a new PoolableConnectionFactory.

Parameters:
connFactory - the ConnectionFactory from which to obtain base Connections
pool - the ObjectPool in which to pool those Connections
stmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement pooling
validationQuery - 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 Connections
defaultAutoCommit - the default "auto commit" setting for returned Connections
Since:
1.3

PoolableConnectionFactory

public PoolableConnectionFactory(ConnectionFactory connFactory,
                                 ObjectPool pool,
                                 KeyedObjectPoolFactory stmtPoolFactory,
                                 String validationQuery,
                                 int validationQueryTimeout,
                                 Collection connectionInitSqls,
                                 boolean defaultReadOnly,
                                 boolean defaultAutoCommit)
Create a new PoolableConnectionFactory.

Parameters:
connFactory - the ConnectionFactory from which to obtain base Connections
pool - the ObjectPool in which to pool those Connections
stmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement pooling
validationQuery - 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 Connections
defaultAutoCommit - the default "auto commit" setting for returned Connections
Since:
1.3

PoolableConnectionFactory

public PoolableConnectionFactory(ConnectionFactory connFactory,
                                 ObjectPool pool,
                                 KeyedObjectPoolFactory stmtPoolFactory,
                                 String validationQuery,
                                 boolean defaultReadOnly,
                                 boolean defaultAutoCommit,
                                 int defaultTransactionIsolation)
Create a new PoolableConnectionFactory.

Parameters:
connFactory - the ConnectionFactory from which to obtain base Connections
pool - the ObjectPool in which to pool those Connections
stmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement pooling
validationQuery - 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 Connections
defaultAutoCommit - the default "auto commit" setting for returned Connections
defaultTransactionIsolation - the default "Transaction Isolation" setting for returned Connections

PoolableConnectionFactory

public PoolableConnectionFactory(ConnectionFactory connFactory,
                                 ObjectPool pool,
                                 KeyedObjectPoolFactory stmtPoolFactory,
                                 String validationQuery,
                                 Collection connectionInitSqls,
                                 boolean defaultReadOnly,
                                 boolean defaultAutoCommit,
                                 int defaultTransactionIsolation)
Create a new PoolableConnectionFactory.

Parameters:
connFactory - the ConnectionFactory from which to obtain base Connections
pool - the ObjectPool in which to pool those Connections
stmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement pooling
validationQuery - 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 Connections
defaultAutoCommit - the default "auto commit" setting for returned Connections
defaultTransactionIsolation - the default "Transaction Isolation" setting for returned Connections
Since:
1.3

PoolableConnectionFactory

public PoolableConnectionFactory(ConnectionFactory connFactory,
                                 ObjectPool pool,
                                 KeyedObjectPoolFactory stmtPoolFactory,
                                 String validationQuery,
                                 int validationQueryTimeout,
                                 boolean defaultReadOnly,
                                 boolean defaultAutoCommit,
                                 int defaultTransactionIsolation)
Create a new PoolableConnectionFactory.

Parameters:
connFactory - the ConnectionFactory from which to obtain base Connections
pool - the ObjectPool in which to pool those Connections
stmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement pooling
validationQuery - 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 Connections
defaultAutoCommit - the default "auto commit" setting for returned Connections
defaultTransactionIsolation - the default "Transaction Isolation" setting for returned Connections
Since:
1.3

PoolableConnectionFactory

public PoolableConnectionFactory(ConnectionFactory connFactory,
                                 ObjectPool pool,
                                 KeyedObjectPoolFactory stmtPoolFactory,
                                 String validationQuery,
                                 int validationQueryTimeout,
                                 Collection connectionInitSqls,
                                 boolean defaultReadOnly,
                                 boolean defaultAutoCommit,
                                 int defaultTransactionIsolation)
Create a new PoolableConnectionFactory.

Parameters:
connFactory - the ConnectionFactory from which to obtain base Connections
pool - the ObjectPool in which to pool those Connections
stmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement pooling
validationQuery - 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 Connections
defaultAutoCommit - the default "auto commit" setting for returned Connections
defaultTransactionIsolation - the default "Transaction Isolation" setting for returned Connections
Since:
1.3

PoolableConnectionFactory

public PoolableConnectionFactory(ConnectionFactory connFactory,
                                 ObjectPool pool,
                                 KeyedObjectPoolFactory stmtPoolFactory,
                                 String validationQuery,
                                 boolean defaultReadOnly,
                                 boolean defaultAutoCommit,
                                 AbandonedConfig config)
Create a new PoolableConnectionFactory.

Parameters:
connFactory - the ConnectionFactory from which to obtain base Connections
pool - the ObjectPool in which to pool those Connections
stmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement pooling
validationQuery - 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 Connections
defaultAutoCommit - the default "auto commit" setting for returned Connections
config - the AbandonedConfig if tracing SQL objects

PoolableConnectionFactory

public PoolableConnectionFactory(ConnectionFactory connFactory,
                                 ObjectPool pool,
                                 KeyedObjectPoolFactory stmtPoolFactory,
                                 String validationQuery,
                                 boolean defaultReadOnly,
                                 boolean defaultAutoCommit,
                                 int defaultTransactionIsolation,
                                 AbandonedConfig config)
Create a new PoolableConnectionFactory.

Parameters:
connFactory - the ConnectionFactory from which to obtain base Connections
pool - the ObjectPool in which to pool those Connections
stmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement pooling
validationQuery - 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 Connections
defaultAutoCommit - the default "auto commit" setting for returned Connections
defaultTransactionIsolation - the default "Transaction Isolation" setting for returned Connections
config - the AbandonedConfig if tracing SQL objects

PoolableConnectionFactory

public PoolableConnectionFactory(ConnectionFactory connFactory,
                                 ObjectPool pool,
                                 KeyedObjectPoolFactory stmtPoolFactory,
                                 String validationQuery,
                                 boolean defaultReadOnly,
                                 boolean defaultAutoCommit,
                                 int defaultTransactionIsolation,
                                 String defaultCatalog,
                                 AbandonedConfig config)
Create a new PoolableConnectionFactory.

Parameters:
connFactory - the ConnectionFactory from which to obtain base Connections
pool - the ObjectPool in which to pool those Connections
stmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement pooling
validationQuery - 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 Connections
defaultAutoCommit - the default "auto commit" setting for returned Connections
defaultTransactionIsolation - the default "Transaction Isolation" setting for returned Connections
defaultCatalog - the default "catalog" setting for returned Connections
config - the AbandonedConfig if tracing SQL objects

PoolableConnectionFactory

public PoolableConnectionFactory(ConnectionFactory connFactory,
                                 ObjectPool pool,
                                 KeyedObjectPoolFactory stmtPoolFactory,
                                 String validationQuery,
                                 Boolean defaultReadOnly,
                                 boolean defaultAutoCommit,
                                 int defaultTransactionIsolation,
                                 String defaultCatalog,
                                 AbandonedConfig config)
Create a new PoolableConnectionFactory.

Parameters:
connFactory - the ConnectionFactory from which to obtain base Connections
pool - the ObjectPool in which to pool those Connections
stmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement pooling
validationQuery - 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 Connections
defaultAutoCommit - the default "auto commit" setting for returned Connections
defaultTransactionIsolation - the default "Transaction Isolation" setting for returned Connections
defaultCatalog - the default "catalog" setting for returned Connections
config - the AbandonedConfig if tracing SQL objects

PoolableConnectionFactory

public PoolableConnectionFactory(ConnectionFactory connFactory,
                                 ObjectPool pool,
                                 KeyedObjectPoolFactory stmtPoolFactory,
                                 String validationQuery,
                                 Collection connectionInitSqls,
                                 Boolean defaultReadOnly,
                                 boolean defaultAutoCommit,
                                 int defaultTransactionIsolation,
                                 String defaultCatalog,
                                 AbandonedConfig config)
Create a new PoolableConnectionFactory.

Parameters:
connFactory - the ConnectionFactory from which to obtain base Connections
pool - the ObjectPool in which to pool those Connections
stmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement pooling
validationQuery - 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 Connections
defaultAutoCommit - the default "auto commit" setting for returned Connections
defaultTransactionIsolation - the default "Transaction Isolation" setting for returned Connections
defaultCatalog - the default "catalog" setting for returned Connections
config - the AbandonedConfig if tracing SQL objects
Since:
1.3

PoolableConnectionFactory

public PoolableConnectionFactory(ConnectionFactory connFactory,
                                 ObjectPool pool,
                                 KeyedObjectPoolFactory stmtPoolFactory,
                                 String validationQuery,
                                 int validationQueryTimeout,
                                 Boolean defaultReadOnly,
                                 boolean defaultAutoCommit,
                                 int defaultTransactionIsolation,
                                 String defaultCatalog,
                                 AbandonedConfig config)
Create a new PoolableConnectionFactory.

Parameters:
connFactory - the ConnectionFactory from which to obtain base Connections
pool - the ObjectPool in which to pool those Connections
stmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement pooling
validationQuery - 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 Connections
defaultAutoCommit - the default "auto commit" setting for returned Connections
defaultTransactionIsolation - the default "Transaction Isolation" setting for returned Connections
defaultCatalog - the default "catalog" setting for returned Connections
config - the AbandonedConfig if tracing SQL objects
Since:
1.3

PoolableConnectionFactory

public PoolableConnectionFactory(ConnectionFactory connFactory,
                                 ObjectPool pool,
                                 KeyedObjectPoolFactory stmtPoolFactory,
                                 String validationQuery,
                                 int validationQueryTimeout,
                                 Collection connectionInitSqls,
                                 Boolean defaultReadOnly,
                                 boolean defaultAutoCommit,
                                 int defaultTransactionIsolation,
                                 String defaultCatalog,
                                 AbandonedConfig config)
Create a new PoolableConnectionFactory.

Parameters:
connFactory - the ConnectionFactory from which to obtain base Connections
pool - the ObjectPool in which to pool those Connections
stmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements, or null to disable PreparedStatement pooling
validationQuery - 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 Connections
defaultAutoCommit - the default "auto commit" setting for returned Connections
defaultTransactionIsolation - the default "Transaction Isolation" setting for returned Connections
defaultCatalog - the default "catalog" setting for returned Connections
config - the AbandonedConfig if tracing SQL objects
Since:
1.3
Method Detail

setConnectionFactory

public void setConnectionFactory(ConnectionFactory connFactory)
Sets the ConnectionFactory from which to obtain base Connections.

Parameters:
connFactory - the ConnectionFactory from which to obtain base Connections

setValidationQuery

public void setValidationQuery(String validationQuery)
Sets the query I use to validate Connections. Should return at least one row. Using null turns off validation.

Parameters:
validationQuery - a query to use to validate Connections.

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(Collection connectionInitSqls)
Sets the SQL statements I use to initialize newly created Connections. Using null turns off connection initialization.

Parameters:
connectionInitSqls - SQL statement to initialize Connections.
Since:
1.3

setPool

public void setPool(ObjectPool pool)
Sets the ObjectPool in which to pool Connections.

Parameters:
pool - the ObjectPool in which to pool those Connections

getPool

public ObjectPool getPool()
Returns the ObjectPool in which Connections are pooled.

Returns:
the connection pool

setStatementPoolFactory

public void setStatementPoolFactory(KeyedObjectPoolFactory stmtPoolFactory)
Sets the KeyedObjectPoolFactory I use to create KeyedObjectPools for pooling PreparedStatements. Set to null to disable PreparedStatement pooling.

Parameters:
stmtPoolFactory - the KeyedObjectPoolFactory to use to create KeyedObjectPools for pooling PreparedStatements

setDefaultReadOnly

public void setDefaultReadOnly(boolean defaultReadOnly)
Sets the default "read only" setting for borrowed Connections

Parameters:
defaultReadOnly - the default "read only" setting for borrowed Connections

setDefaultAutoCommit

public void setDefaultAutoCommit(boolean defaultAutoCommit)
Sets the default "auto commit" setting for borrowed Connections

Parameters:
defaultAutoCommit - the default "auto commit" setting for borrowed Connections

setDefaultTransactionIsolation

public void setDefaultTransactionIsolation(int defaultTransactionIsolation)
Sets the default "Transaction Isolation" setting for borrowed Connections

Parameters:
defaultTransactionIsolation - the default "Transaction Isolation" setting for returned Connections

setDefaultCatalog

public void setDefaultCatalog(String defaultCatalog)
Sets the default "catalog" setting for borrowed Connections

Parameters:
defaultCatalog - the default "catalog" setting for borrowed Connections

makeObject

public Object makeObject()
                  throws Exception
Description copied from interface: PoolableObjectFactory
Creates an instance that can be served by the pool. Instances returned from this method should be in the same state as if they had been activated. They will not be activated before being served by the pool.

Specified by:
makeObject in interface PoolableObjectFactory
Returns:
an instance that can be served by the pool.
Throws:
Exception - if there is a problem creating a new instance, this will be propagated to the code requesting an object.

initializeConnection

protected void initializeConnection(Connection conn)
                             throws SQLException
Throws:
SQLException

destroyObject

public void destroyObject(Object obj)
                   throws Exception
Description copied from interface: PoolableObjectFactory
Destroys an instance no longer needed by the pool.

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.

Specified by:
destroyObject in interface PoolableObjectFactory
Parameters:
obj - the instance to be destroyed
Throws:
Exception - should be avoided as it may be swallowed by the pool implementation.
See Also:
PoolableObjectFactory.validateObject(java.lang.Object), ObjectPool.invalidateObject(java.lang.Object)

validateObject

public boolean validateObject(Object obj)
Description copied from interface: PoolableObjectFactory
Ensures that the instance is safe to be returned by the pool. Returns false if obj should be destroyed.

Specified by:
validateObject in interface PoolableObjectFactory
Parameters:
obj - the instance to be validated
Returns:
false if obj is not valid and should be dropped from the pool, true otherwise.

validateConnection

public void validateConnection(Connection conn)
                        throws SQLException
Throws:
SQLException

passivateObject

public void passivateObject(Object obj)
                     throws Exception
Description copied from interface: PoolableObjectFactory
Uninitialize an instance to be returned to the idle object pool.

Specified by:
passivateObject in interface PoolableObjectFactory
Parameters:
obj - the instance to be passivated
Throws:
Exception - if there is a problem passivating obj, this exception may be swallowed by the pool.
See Also:
PoolableObjectFactory.destroyObject(java.lang.Object)

activateObject

public void activateObject(Object obj)
                    throws Exception
Description copied from interface: PoolableObjectFactory
Reinitialize an instance to be returned by the pool.

Specified by:
activateObject in interface PoolableObjectFactory
Parameters:
obj - the instance to be activated
Throws:
Exception - if there is a problem activating obj, this exception may be swallowed by the pool.
See Also:
PoolableObjectFactory.destroyObject(java.lang.Object)


Copyright © 2012. All Rights Reserved.