org.apache.commons.dbcp
public class PoolingConnection extends DelegatingConnection implements Connection, KeyedPoolableObjectFactory
My PoolingConnection methods, rather than creating a new PreparedStatement each time, may actually pull the PreparedStatement from a pool of unused statements. The PreparedStatement#close method of the returned PreparedStatement doesn't actually close the statement, but rather returns it to my pool. (See PoolablePreparedStatement.)
Version: $Revision: 1.14 $ $Date: 2004/03/07 15:26:38 $
See Also: PoolablePreparedStatement
| Constructor Summary | |
|---|---|
| PoolingConnection(Connection c)
Constructor. | |
| PoolingConnection(Connection c, KeyedObjectPool pool)
Constructor. | |
| Method Summary | |
|---|---|
| void | activateObject(Object key, Object obj)
My KeyedPoolableObjectFactory method for activating
PreparedStatements. |
| void | close()
Close and free all PreparedStatements from my pool, and
close my underlying connection. |
| void | destroyObject(Object key, Object obj)
My KeyedPoolableObjectFactory method for destroying
PreparedStatements. |
| Object | makeObject(Object obj)
My KeyedPoolableObjectFactory method for creating
PreparedStatements. |
| void | passivateObject(Object key, Object obj)
My KeyedPoolableObjectFactory method for passivating
PreparedStatements. |
| PreparedStatement | prepareStatement(String sql)
Create or obtain a PreparedStatement from my pool. |
| PreparedStatement | prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
Create or obtain a PreparedStatement from my pool. |
| String | toString() |
| boolean | validateObject(Object key, Object obj)
My KeyedPoolableObjectFactory method for validating
PreparedStatements. |
Parameters: c the underlying Connection.
Parameters: c the underlying Connection. maxSleepingPerKey the maximum number of PreparedStatements that may sit idle in my pool (per type)
Parameters: key ignored obj ignored
Parameters: key ignored obj the PreparedStatement to be destroyed.
Parameters: obj the key for the PreparedStatement to be created
Parameters: key ignored obj a PreparedStatement
Returns: a PoolablePreparedStatement
Returns: a PoolablePreparedStatement
Parameters: key ignored obj ignored
Returns: true