java.lang.Object
org.apache.commons.dbcp.AbandonedTrace
org.apache.commons.dbcp.DelegatingConnection
org.apache.commons.dbcp.PoolingConnection
- All Implemented Interfaces:
- java.sql.Connection, org.apache.commons.pool.KeyedPoolableObjectFactory
- public class PoolingConnection
- extends DelegatingConnection
- implements java.sql.Connection, org.apache.commons.pool.KeyedPoolableObjectFactory
A DelegatingConnection that pools java.sql.PreparedStatements.
My prepareStatement(java.lang.String) 55 methods, rather than creating a new java.sql.PreparedStatement
each time, may actually pull the java.sql.PreparedStatement from a pool of unused statements.
The Statement.close()>Statement.close() 55 method of the returned java.sql.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 $
|
Method Summary |
void |
activateObject(java.lang.Object key,
java.lang.Object obj)
My org.apache.commons.pool.KeyedPoolableObjectFactory method for activating
java.sql.PreparedStatements. |
void |
close()
Close and free all java.sql.PreparedStatements from my pool, and
close my underlying connection. |
protected java.lang.Object |
createKey(java.lang.String sql)
Create a PStmtKey for the given arguments. |
protected java.lang.Object |
createKey(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
Create a PStmtKey for the given arguments. |
void |
destroyObject(java.lang.Object key,
java.lang.Object obj)
My org.apache.commons.pool.KeyedPoolableObjectFactory method for destroying
java.sql.PreparedStatements. |
java.lang.Object |
makeObject(java.lang.Object obj)
My org.apache.commons.pool.KeyedPoolableObjectFactory method for creating
java.sql.PreparedStatements. |
protected java.lang.String |
normalizeSQL(java.lang.String sql)
Normalize the given SQL statement, producing a
cannonical form that is semantically equivalent to the original. |
void |
passivateObject(java.lang.Object key,
java.lang.Object obj)
My org.apache.commons.pool.KeyedPoolableObjectFactory method for passivating
java.sql.PreparedStatements. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql)
Create or obtain a java.sql.PreparedStatement from my pool. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
Create or obtain a java.sql.PreparedStatement from my pool. |
java.lang.String |
toString()
Convert this Object to a human-readable String. |
boolean |
validateObject(java.lang.Object key,
java.lang.Object obj)
My org.apache.commons.pool.KeyedPoolableObjectFactory method for validating
java.sql.PreparedStatements. |
| Methods inherited from class org.apache.commons.dbcp.DelegatingConnection |
activate, checkOpen, clearWarnings, commit, createStatement, createStatement, createStatement, equals, getAutoCommit, getCatalog, getDelegate, getHoldability, getInnermostDelegate, getMetaData, getTransactionIsolation, getTypeMap, getWarnings, handleException, hashCode, isClosed, isReadOnly, nativeSQL, passivate, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, rollback, setAutoCommit, setCatalog, setDelegate, setHoldability, setReadOnly, setSavepoint, setSavepoint, setTransactionIsolation, setTypeMap |
| Methods inherited from interface java.sql.Connection |
clearWarnings, commit, createStatement, createStatement, createStatement, getAutoCommit, getCatalog, getHoldability, getMetaData, getTransactionIsolation, getTypeMap, getWarnings, isClosed, isReadOnly, nativeSQL, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, rollback, setAutoCommit, setCatalog, setHoldability, setReadOnly, setSavepoint, setSavepoint, setTransactionIsolation, setTypeMap |
_pstmtPool
protected org.apache.commons.pool.KeyedObjectPool _pstmtPool
- My pool of java.sql.PreparedStatements.
PoolingConnection
public PoolingConnection(java.sql.Connection c)
- Constructor.
PoolingConnection
public PoolingConnection(java.sql.Connection c,
org.apache.commons.pool.KeyedObjectPool pool)
- Constructor.
close
public void close()
throws java.sql.SQLException
- Close and free all java.sql.PreparedStatements from my pool, and
close my underlying connection.
- Specified by:
close in interface java.sql.Connection- Overrides:
close in class DelegatingConnection
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
throws java.sql.SQLException
- Create or obtain a java.sql.PreparedStatement from my pool.
- Specified by:
prepareStatement in interface java.sql.Connection- Overrides:
prepareStatement in class DelegatingConnection
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
- Create or obtain a java.sql.PreparedStatement from my pool.
- Specified by:
prepareStatement in interface java.sql.Connection- Overrides:
prepareStatement in class DelegatingConnection
createKey
protected java.lang.Object createKey(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
- Create a PStmtKey for the given arguments.
createKey
protected java.lang.Object createKey(java.lang.String sql)
- Create a PStmtKey for the given arguments.
normalizeSQL
protected java.lang.String normalizeSQL(java.lang.String sql)
- Normalize the given SQL statement, producing a
cannonical form that is semantically equivalent to the original.
makeObject
public java.lang.Object makeObject(java.lang.Object obj)
throws java.lang.Exception
- My org.apache.commons.pool.KeyedPoolableObjectFactory method for creating
java.sql.PreparedStatements.
- Specified by:
makeObject in interface org.apache.commons.pool.KeyedPoolableObjectFactory
destroyObject
public void destroyObject(java.lang.Object key,
java.lang.Object obj)
throws java.lang.Exception
- My org.apache.commons.pool.KeyedPoolableObjectFactory method for destroying
java.sql.PreparedStatements.
- Specified by:
destroyObject in interface org.apache.commons.pool.KeyedPoolableObjectFactory
validateObject
public boolean validateObject(java.lang.Object key,
java.lang.Object obj)
- My org.apache.commons.pool.KeyedPoolableObjectFactory method for validating
java.sql.PreparedStatements.
- Specified by:
validateObject in interface org.apache.commons.pool.KeyedPoolableObjectFactory
activateObject
public void activateObject(java.lang.Object key,
java.lang.Object obj)
throws java.lang.Exception
- My org.apache.commons.pool.KeyedPoolableObjectFactory method for activating
java.sql.PreparedStatements. (Currently a no-op.)
- Specified by:
activateObject in interface org.apache.commons.pool.KeyedPoolableObjectFactory
passivateObject
public void passivateObject(java.lang.Object key,
java.lang.Object obj)
throws java.lang.Exception
- My org.apache.commons.pool.KeyedPoolableObjectFactory method for passivating
java.sql.PreparedStatements. Currently invokes PreparedStatement.clearParameters()>
PreparedStatement.clearParameters() 55 .
- Specified by:
passivateObject in interface org.apache.commons.pool.KeyedPoolableObjectFactory
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object
- Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method
never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string
concatenation with this object. If the result is
null, string concatenation will instead
use "null".
The default implementation returns
getClass().getName() + "@" +
Integer.toHexString(hashCode()).