public class PoolingConnection extends DelegatingConnection implements Connection, KeyedPoolableObjectFactory
DelegatingConnection that pools PreparedStatements.
The prepareStatement(java.lang.String) and prepareCall(java.lang.String) methods, rather than creating a new PreparedStatement
each time, may actually pull the statement from a pool of unused statements.
The Statement.close() method of the returned statement doesn't
actually close the statement, but rather returns it to the pool.
(See PoolablePreparedStatement, PoolableCallableStatement.)
PoolablePreparedStatementTRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE| Constructor and Description |
|---|
PoolingConnection(Connection c)
Constructor.
|
PoolingConnection(Connection c,
KeyedObjectPool pool)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abort(Executor executor) |
void |
activateObject(Object key,
Object obj)
KeyedPoolableObjectFactory method for activating
pooled statements. |
void |
close()
Close and free all
PreparedStatements or CallableStatement from the pool, and
close the underlying connection. |
void |
destroyObject(Object key,
Object obj)
KeyedPoolableObjectFactory method for destroying
PoolablePreparedStatements and PoolableCallableStatements. |
int |
getNetworkTimeout() |
String |
getSchema() |
Object |
makeObject(Object obj)
KeyedPoolableObjectFactory method for creating
PoolablePreparedStatements or PoolableCallableStatements. |
void |
passivateObject(Object key,
Object obj)
|
CallableStatement |
prepareCall(String sql)
Create or obtain a
CallableStatement from the pool. |
CallableStatement |
prepareCall(String sql,
int resultSetType,
int resultSetConcurrency)
Create or obtain a
CallableStatement from the pool. |
PreparedStatement |
prepareStatement(String sql)
Create or obtain a
PreparedStatement from the pool. |
PreparedStatement |
prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency)
Create or obtain a
PreparedStatement from the pool. |
void |
setNetworkTimeout(Executor executor,
int milliseconds) |
void |
setSchema(String schema) |
String |
toString()
Returns a string representation of the metadata associated with
the innnermost delegate connection.
|
boolean |
validateObject(Object key,
Object obj)
KeyedPoolableObjectFactory method for validating
pooled statements. |
clearWarnings, commit, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStatement, createStatement, createStatement, createStruct, equals, getAutoCommit, getCatalog, getClientInfo, getClientInfo, getDelegate, getHoldability, getInnermostDelegate, getMetaData, getTransactionIsolation, getTypeMap, getWarnings, hashCode, innermostDelegateEquals, isClosed, isReadOnly, isValid, isWrapperFor, nativeSQL, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, rollback, setAutoCommit, setCatalog, setClientInfo, setClientInfo, setDelegate, setHoldability, setReadOnly, setSavepoint, setSavepoint, setTransactionIsolation, setTypeMap, unwrapprintStackTraceclearWarnings, commit, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStatement, createStatement, createStatement, createStruct, getAutoCommit, getCatalog, getClientInfo, getClientInfo, getHoldability, getMetaData, getTransactionIsolation, getTypeMap, getWarnings, isClosed, isReadOnly, isValid, nativeSQL, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, rollback, setAutoCommit, setCatalog, setClientInfo, setClientInfo, setHoldability, setReadOnly, setSavepoint, setSavepoint, setTransactionIsolation, setTypeMapisWrapperFor, unwrappublic PoolingConnection(Connection c)
c - the underlying Connection.public PoolingConnection(Connection c, KeyedObjectPool pool)
c - the underlying Connection.pool - KeyedObjectPool of PreparedStatements and CallableStatements.public void abort(Executor executor) throws SQLException
abort in interface Connectionabort in class DelegatingConnectionSQLExceptionpublic void activateObject(Object key, Object obj) throws Exception
KeyedPoolableObjectFactory method for activating
pooled statements.activateObject in interface KeyedPoolableObjectFactorykey - ignoredobj - pooled statement to be activatedExceptionpublic void close()
throws SQLException
PreparedStatements or CallableStatement from the pool, and
close the underlying connection.close in interface AutoCloseableclose in interface Connectionclose in class DelegatingConnectionSQLExceptionpublic void destroyObject(Object key, Object obj) throws Exception
KeyedPoolableObjectFactory method for destroying
PoolablePreparedStatements and PoolableCallableStatements.
Closes the underlying statement.destroyObject in interface KeyedPoolableObjectFactorykey - ignoredobj - the pooled statement to be destroyed.Exceptionpublic int getNetworkTimeout()
throws SQLException
getNetworkTimeout in interface ConnectiongetNetworkTimeout in class DelegatingConnectionSQLExceptionpublic String getSchema() throws SQLException
getSchema in interface ConnectiongetSchema in class DelegatingConnectionSQLExceptionpublic Object makeObject(Object obj) throws Exception
KeyedPoolableObjectFactory method for creating
PoolablePreparedStatements or PoolableCallableStatements.
The stmtType field in the key determines whether
a PoolablePreparedStatement or PoolableCallableStatement is created.makeObject in interface KeyedPoolableObjectFactoryobj - the key for the PreparedStatement to be createdExceptioncreateKey(String, int, int, byte)public void passivateObject(Object key, Object obj) throws Exception
KeyedPoolableObjectFactory method for passivating
PreparedStatements or CallableStatements.
Invokes PreparedStatement.clearParameters().passivateObject in interface KeyedPoolableObjectFactorykey - ignoredobj - a PreparedStatementExceptionpublic CallableStatement prepareCall(String sql) throws SQLException
CallableStatement from the pool.prepareCall in interface ConnectionprepareCall in class DelegatingConnectionsql - the sql string used to define the CallableStatementPoolableCallableStatementSQLExceptionpublic CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
CallableStatement from the pool.prepareCall in interface ConnectionprepareCall in class DelegatingConnectionsql - the sql string used to define the CallableStatementresultSetType - result set typeresultSetConcurrency - result set concurrencyPoolableCallableStatementSQLExceptionpublic PreparedStatement prepareStatement(String sql) throws SQLException
PreparedStatement from the pool.prepareStatement in interface ConnectionprepareStatement in class DelegatingConnectionsql - the sql string used to define the PreparedStatementPoolablePreparedStatementSQLExceptionpublic PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
PreparedStatement from the pool.prepareStatement in interface ConnectionprepareStatement in class DelegatingConnectionsql - the sql string used to define the PreparedStatementresultSetType - result set typeresultSetConcurrency - result set concurrencyPoolablePreparedStatementSQLExceptionpublic void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException
setNetworkTimeout in interface ConnectionsetNetworkTimeout in class DelegatingConnectionSQLExceptionpublic void setSchema(String schema) throws SQLException
setSchema in interface ConnectionsetSchema in class DelegatingConnectionSQLExceptionpublic String toString()
DelegatingConnectiontoString in class DelegatingConnectionpublic boolean validateObject(Object key, Object obj)
KeyedPoolableObjectFactory method for validating
pooled statements. Currently always returns true.validateObject in interface KeyedPoolableObjectFactorykey - ignoredobj - ignoredCopyright © 2001-2004 Apache Software Foundation. Documenation generated July 9 2012.