|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.dbcp.AbandonedTrace
org.apache.commons.dbcp.DelegatingConnection
org.apache.commons.dbcp.PoolingConnection
public class PoolingConnection
A 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.)
PoolablePreparedStatement| Field Summary | |
|---|---|
protected org.apache.commons.pool.KeyedObjectPool |
_pstmtPool
Pool of PreparedStatements. |
| Fields inherited from class org.apache.commons.dbcp.DelegatingConnection |
|---|
_closed, _conn |
| Fields inherited from interface java.sql.Connection |
|---|
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE |
| Constructor Summary | |
|---|---|
PoolingConnection(Connection c)
Constructor. |
|
PoolingConnection(Connection c,
org.apache.commons.pool.KeyedObjectPool pool)
Constructor. |
|
| Method Summary | |
|---|---|
void |
activateObject(Object key,
Object obj)
KeyedPoolableObjectFactory method for activating
pooled statements. |
void |
close()
Close and free all PreparedStatements or CallableStatement from my pool, and
close my underlying connection. |
protected Object |
createKey(String sql)
Create a PStmtKey for the given arguments. |
protected Object |
createKey(String sql,
byte stmtType)
Create a PStmtKey for the given arguments. |
protected Object |
createKey(String sql,
int resultSetType,
int resultSetConcurrency)
Create a PStmtKey for the given arguments. |
protected Object |
createKey(String sql,
int resultSetType,
int resultSetConcurrency,
byte stmtType)
Create a PStmtKey for the given arguments. |
void |
destroyObject(Object key,
Object obj)
KeyedPoolableObjectFactory method for destroying
PoolablePreparedStatements and PoolableCallableStatements. |
Object |
makeObject(Object obj)
KeyedPoolableObjectFactory method for creating
PoolablePreparedStatements or PoolableCallableStatements. |
protected String |
normalizeSQL(String sql)
Normalize the given SQL statement, producing a cannonical form that is semantically equivalent to the original. |
void |
passivateObject(Object key,
Object obj)
KeyedPoolableObjectFactory method for passivating
PreparedStatements or CallableStatements. |
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 my pool. |
PreparedStatement |
prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency)
Create or obtain a PreparedStatement from my pool. |
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. |
| Methods inherited from class org.apache.commons.dbcp.AbandonedTrace |
|---|
addTrace, clearTrace, getConfig, getLastUsed, getTrace, printStackTrace, removeTrace, setLastUsed, setLastUsed, setStackTrace |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.sql.Wrapper |
|---|
isWrapperFor, unwrap |
| Field Detail |
|---|
protected org.apache.commons.pool.KeyedObjectPool _pstmtPool
PreparedStatements. and CallableStatements
| Constructor Detail |
|---|
public PoolingConnection(Connection c)
c - the underlying Connection.
public PoolingConnection(Connection c,
org.apache.commons.pool.KeyedObjectPool pool)
c - the underlying Connection.pool - KeyedObjectPool of PreparedStatements and CallableStatements.| Method Detail |
|---|
public void close()
throws SQLException
PreparedStatements or CallableStatement from my pool, and
close my underlying connection.
close in interface Connectionclose in class DelegatingConnectionSQLException
public PreparedStatement prepareStatement(String sql)
throws SQLException
PreparedStatement from my pool.
prepareStatement in interface ConnectionprepareStatement in class DelegatingConnectionPoolablePreparedStatement
SQLException
public PreparedStatement prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency)
throws SQLException
PreparedStatement from my pool.
prepareStatement in interface ConnectionprepareStatement in class DelegatingConnectionPoolablePreparedStatement
SQLException
public CallableStatement prepareCall(String sql)
throws SQLException
CallableStatement from the pool.
prepareCall in interface ConnectionprepareCall in class DelegatingConnectionsql - the sql string used to define the CallableStatement
PoolableCallableStatement
SQLException
public 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 CallableStatement
PoolableCallableStatement
SQLException
protected Object createKey(String sql,
int resultSetType,
int resultSetConcurrency)
protected Object createKey(String sql,
int resultSetType,
int resultSetConcurrency,
byte stmtType)
protected Object createKey(String sql)
protected Object createKey(String sql,
byte stmtType)
protected String normalizeSQL(String sql)
public Object makeObject(Object obj)
throws Exception
KeyedPoolableObjectFactory method for creating
PoolablePreparedStatements or PoolableCallableStatements.
The PStmtKey#_stmtType field in the key determines whether
a PoolablePreparedStatement or PoolableCallableStatement is created.
makeObject in interface org.apache.commons.pool.KeyedPoolableObjectFactoryobj - the key for the PreparedStatement to be created
Exception
public void destroyObject(Object key,
Object obj)
throws Exception
KeyedPoolableObjectFactory method for destroying
PoolablePreparedStatements and PoolableCallableStatements.
Closes the underlying statement.
destroyObject in interface org.apache.commons.pool.KeyedPoolableObjectFactorykey - ignoredobj - the pooled statement to be destroyed.
Exception
public boolean validateObject(Object key,
Object obj)
KeyedPoolableObjectFactory method for validating
pooled statements. Currently always returns true.
validateObject in interface org.apache.commons.pool.KeyedPoolableObjectFactorykey - ignoredobj - ignored
public void activateObject(Object key,
Object obj)
throws Exception
KeyedPoolableObjectFactory method for activating
pooled statements.
activateObject in interface org.apache.commons.pool.KeyedPoolableObjectFactorykey - ignoredobj - pooled statement to be activated
Exception
public void passivateObject(Object key,
Object obj)
throws Exception
KeyedPoolableObjectFactory method for passivating
PreparedStatements or CallableStatements.
Invokes PreparedStatement.clearParameters().
passivateObject in interface org.apache.commons.pool.KeyedPoolableObjectFactorykey - ignoredobj - a PreparedStatement
Exceptionpublic String toString()
DelegatingConnection
toString in class DelegatingConnection
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||