org.apache.commons.dbcp

Class PoolingConnection

public class PoolingConnection extends DelegatingConnection implements Connection, KeyedPoolableObjectFactory

A DelegatingConnection that pools PreparedStatements.

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: 498524 $ $Date: 2007-01-21 21:44:45 -0700 (Sun, 21 Jan 2007) $

Author: Rodney Waldhoff Dirk Verbeeck

See Also: PoolablePreparedStatement

Constructor Summary
PoolingConnection(Connection c)
Constructor.
PoolingConnection(Connection c, KeyedObjectPool pool)
Constructor.
Method Summary
voidactivateObject(Object key, Object obj)
My KeyedPoolableObjectFactory method for activating PreparedStatements.
voidclose()
Close and free all PreparedStatements from my pool, and close my underlying connection.
voiddestroyObject(Object key, Object obj)
My KeyedPoolableObjectFactory method for destroying PreparedStatements.
ObjectmakeObject(Object obj)
My KeyedPoolableObjectFactory method for creating PreparedStatements.
voidpassivateObject(Object key, Object obj)
My KeyedPoolableObjectFactory method for passivating PreparedStatements.
PreparedStatementprepareStatement(String sql)
Create or obtain a PreparedStatement from my pool.
PreparedStatementprepareStatement(String sql, int resultSetType, int resultSetConcurrency)
Create or obtain a PreparedStatement from my pool.
StringtoString()
booleanvalidateObject(Object key, Object obj)
My KeyedPoolableObjectFactory method for validating PreparedStatements.

Constructor Detail

PoolingConnection

public PoolingConnection(Connection c)
Constructor.

Parameters: c the underlying Connection.

PoolingConnection

public PoolingConnection(Connection c, KeyedObjectPool pool)
Constructor.

Parameters: c the underlying Connection. pool KeyedObjectPool of PreparedStatements

Method Detail

activateObject

public void activateObject(Object key, Object obj)
My KeyedPoolableObjectFactory method for activating PreparedStatements. (Currently a no-op.)

Parameters: key ignored obj ignored

close

public void close()
Close and free all PreparedStatements from my pool, and close my underlying connection.

destroyObject

public void destroyObject(Object key, Object obj)
My KeyedPoolableObjectFactory method for destroying PreparedStatements.

Parameters: key ignored obj the PreparedStatement to be destroyed.

makeObject

public Object makeObject(Object obj)
My KeyedPoolableObjectFactory method for creating PreparedStatements.

Parameters: obj the key for the PreparedStatement to be created

passivateObject

public void passivateObject(Object key, Object obj)
My KeyedPoolableObjectFactory method for passivating PreparedStatements. Currently invokes PreparedStatement#clearParameters.

Parameters: key ignored obj a PreparedStatement

prepareStatement

public PreparedStatement prepareStatement(String sql)
Create or obtain a PreparedStatement from my pool.

Returns: a PoolablePreparedStatement

prepareStatement

public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
Create or obtain a PreparedStatement from my pool.

Returns: a PoolablePreparedStatement

toString

public String toString()

validateObject

public boolean validateObject(Object key, Object obj)
My KeyedPoolableObjectFactory method for validating PreparedStatements.

Parameters: key ignored obj ignored

Returns: true

Copyright © 2001-2004 Apache Software Foundation. Documenation generated December 10 2007.