Package org.apache.commons.dbcp
Class PoolingDataSource.PoolGuardConnectionWrapper
- java.lang.Object
-
- org.apache.commons.dbcp.AbandonedTrace
-
- org.apache.commons.dbcp.DelegatingConnection
-
- org.apache.commons.dbcp.PoolingDataSource.PoolGuardConnectionWrapper
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,java.sql.Connection
,java.sql.Wrapper
- Enclosing class:
- PoolingDataSource
private class PoolingDataSource.PoolGuardConnectionWrapper extends DelegatingConnection
PoolGuardConnectionWrapper is a Connection wrapper that makes sure a closed connection cannot be used anymore.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.commons.dbcp.AbandonedTrace
AbandonedTrace.AbandonedObjectException
-
-
Field Summary
Fields Modifier and Type Field Description private java.sql.Connection
delegate
-
Fields inherited from class org.apache.commons.dbcp.DelegatingConnection
_closed, _conn
-
-
Constructor Summary
Constructors Constructor Description PoolGuardConnectionWrapper(java.sql.Connection delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkOpen()
void
clearWarnings()
void
close()
Closes the underlying connection, and close any Statements that were not explicitly closed.void
commit()
java.sql.Statement
createStatement()
java.sql.Statement
createStatement(int resultSetType, int resultSetConcurrency)
java.sql.Statement
createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
boolean
equals(java.lang.Object obj)
This method considers two objects to be equal if the underlying jdbc objects are equal.boolean
getAutoCommit()
java.lang.String
getCatalog()
java.sql.Connection
getDelegate()
Returns my underlyingConnection
.int
getHoldability()
java.sql.Connection
getInnermostDelegate()
If my underlyingConnection
is not a DelegatingConnection, returns it, otherwise recursively invokes this method on my delegate.java.sql.DatabaseMetaData
getMetaData()
int
getTransactionIsolation()
java.util.Map
getTypeMap()
java.sql.SQLWarning
getWarnings()
int
hashCode()
boolean
innermostDelegateEquals(java.sql.Connection c)
Compares innermost delegate to the given connection.boolean
isClosed()
boolean
isReadOnly()
java.lang.String
nativeSQL(java.lang.String sql)
java.sql.CallableStatement
prepareCall(java.lang.String sql)
java.sql.CallableStatement
prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)
java.sql.CallableStatement
prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
java.sql.PreparedStatement
prepareStatement(java.lang.String sql)
java.sql.PreparedStatement
prepareStatement(java.lang.String sql, int autoGeneratedKeys)
java.sql.PreparedStatement
prepareStatement(java.lang.String sql, int[] columnIndexes)
java.sql.PreparedStatement
prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)
java.sql.PreparedStatement
prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
java.sql.PreparedStatement
prepareStatement(java.lang.String sql, java.lang.String[] columnNames)
void
releaseSavepoint(java.sql.Savepoint savepoint)
void
rollback()
void
rollback(java.sql.Savepoint savepoint)
void
setAutoCommit(boolean autoCommit)
void
setCatalog(java.lang.String catalog)
void
setHoldability(int holdability)
void
setReadOnly(boolean readOnly)
java.sql.Savepoint
setSavepoint()
java.sql.Savepoint
setSavepoint(java.lang.String name)
void
setTransactionIsolation(int level)
void
setTypeMap(java.util.Map map)
java.lang.String
toString()
Returns a string representation of the metadata associated with the innnermost delegate connection.-
Methods inherited from class org.apache.commons.dbcp.DelegatingConnection
abort, activate, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStruct, getClientInfo, getClientInfo, getDelegateInternal, getInnermostDelegateInternal, getNetworkTimeout, getSchema, handleException, isValid, isWrapperFor, passivate, setClientInfo, setClientInfo, setDelegate, setNetworkTimeout, setSchema, unwrap
-
Methods inherited from class org.apache.commons.dbcp.AbandonedTrace
addTrace, clearTrace, getConfig, getLastUsed, getTrace, printStackTrace, removeTrace, setLastUsed, setLastUsed, setStackTrace
-
-
-
-
Method Detail
-
checkOpen
protected void checkOpen() throws java.sql.SQLException
- Overrides:
checkOpen
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
close
public void close() throws java.sql.SQLException
Description copied from class:DelegatingConnection
Closes the underlying connection, and close any Statements that were not explicitly closed.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.sql.Connection
- Overrides:
close
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
isClosed
public boolean isClosed() throws java.sql.SQLException
- Specified by:
isClosed
in interfacejava.sql.Connection
- Overrides:
isClosed
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
clearWarnings
public void clearWarnings() throws java.sql.SQLException
- Specified by:
clearWarnings
in interfacejava.sql.Connection
- Overrides:
clearWarnings
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
commit
public void commit() throws java.sql.SQLException
- Specified by:
commit
in interfacejava.sql.Connection
- Overrides:
commit
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
createStatement
public java.sql.Statement createStatement() throws java.sql.SQLException
- Specified by:
createStatement
in interfacejava.sql.Connection
- Overrides:
createStatement
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
createStatement
public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
- Specified by:
createStatement
in interfacejava.sql.Connection
- Overrides:
createStatement
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
innermostDelegateEquals
public boolean innermostDelegateEquals(java.sql.Connection c)
Description copied from class:DelegatingConnection
Compares innermost delegate to the given connection.- Overrides:
innermostDelegateEquals
in classDelegatingConnection
- Parameters:
c
- connection to compare innermost delegate with- Returns:
- true if innermost delegate equals
c
-
getAutoCommit
public boolean getAutoCommit() throws java.sql.SQLException
- Specified by:
getAutoCommit
in interfacejava.sql.Connection
- Overrides:
getAutoCommit
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
getCatalog
public java.lang.String getCatalog() throws java.sql.SQLException
- Specified by:
getCatalog
in interfacejava.sql.Connection
- Overrides:
getCatalog
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
getMetaData
public java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLException
- Specified by:
getMetaData
in interfacejava.sql.Connection
- Overrides:
getMetaData
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
getTransactionIsolation
public int getTransactionIsolation() throws java.sql.SQLException
- Specified by:
getTransactionIsolation
in interfacejava.sql.Connection
- Overrides:
getTransactionIsolation
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
getTypeMap
public java.util.Map getTypeMap() throws java.sql.SQLException
- Specified by:
getTypeMap
in interfacejava.sql.Connection
- Overrides:
getTypeMap
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
getWarnings
public java.sql.SQLWarning getWarnings() throws java.sql.SQLException
- Specified by:
getWarnings
in interfacejava.sql.Connection
- Overrides:
getWarnings
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classDelegatingConnection
-
equals
public boolean equals(java.lang.Object obj)
Description copied from class:DelegatingConnection
This method considers two objects to be equal if the underlying jdbc objects are equal.- Overrides:
equals
in classDelegatingConnection
-
isReadOnly
public boolean isReadOnly() throws java.sql.SQLException
- Specified by:
isReadOnly
in interfacejava.sql.Connection
- Overrides:
isReadOnly
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
nativeSQL
public java.lang.String nativeSQL(java.lang.String sql) throws java.sql.SQLException
- Specified by:
nativeSQL
in interfacejava.sql.Connection
- Overrides:
nativeSQL
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql) throws java.sql.SQLException
- Specified by:
prepareCall
in interfacejava.sql.Connection
- Overrides:
prepareCall
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
- Specified by:
prepareCall
in interfacejava.sql.Connection
- Overrides:
prepareCall
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException
- Specified by:
prepareStatement
in interfacejava.sql.Connection
- Overrides:
prepareStatement
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
- Specified by:
prepareStatement
in interfacejava.sql.Connection
- Overrides:
prepareStatement
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
rollback
public void rollback() throws java.sql.SQLException
- Specified by:
rollback
in interfacejava.sql.Connection
- Overrides:
rollback
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
setAutoCommit
public void setAutoCommit(boolean autoCommit) throws java.sql.SQLException
- Specified by:
setAutoCommit
in interfacejava.sql.Connection
- Overrides:
setAutoCommit
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
setCatalog
public void setCatalog(java.lang.String catalog) throws java.sql.SQLException
- Specified by:
setCatalog
in interfacejava.sql.Connection
- Overrides:
setCatalog
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
setReadOnly
public void setReadOnly(boolean readOnly) throws java.sql.SQLException
- Specified by:
setReadOnly
in interfacejava.sql.Connection
- Overrides:
setReadOnly
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
setTransactionIsolation
public void setTransactionIsolation(int level) throws java.sql.SQLException
- Specified by:
setTransactionIsolation
in interfacejava.sql.Connection
- Overrides:
setTransactionIsolation
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
setTypeMap
public void setTypeMap(java.util.Map map) throws java.sql.SQLException
- Specified by:
setTypeMap
in interfacejava.sql.Connection
- Overrides:
setTypeMap
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
toString
public java.lang.String toString()
Description copied from class:DelegatingConnection
Returns a string representation of the metadata associated with the innnermost delegate connection.- Overrides:
toString
in classDelegatingConnection
-
getHoldability
public int getHoldability() throws java.sql.SQLException
- Specified by:
getHoldability
in interfacejava.sql.Connection
- Overrides:
getHoldability
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
setHoldability
public void setHoldability(int holdability) throws java.sql.SQLException
- Specified by:
setHoldability
in interfacejava.sql.Connection
- Overrides:
setHoldability
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
setSavepoint
public java.sql.Savepoint setSavepoint() throws java.sql.SQLException
- Specified by:
setSavepoint
in interfacejava.sql.Connection
- Overrides:
setSavepoint
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
setSavepoint
public java.sql.Savepoint setSavepoint(java.lang.String name) throws java.sql.SQLException
- Specified by:
setSavepoint
in interfacejava.sql.Connection
- Overrides:
setSavepoint
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
releaseSavepoint
public void releaseSavepoint(java.sql.Savepoint savepoint) throws java.sql.SQLException
- Specified by:
releaseSavepoint
in interfacejava.sql.Connection
- Overrides:
releaseSavepoint
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
rollback
public void rollback(java.sql.Savepoint savepoint) throws java.sql.SQLException
- Specified by:
rollback
in interfacejava.sql.Connection
- Overrides:
rollback
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
createStatement
public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
- Specified by:
createStatement
in interfacejava.sql.Connection
- Overrides:
createStatement
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
- Specified by:
prepareCall
in interfacejava.sql.Connection
- Overrides:
prepareCall
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException
- Specified by:
prepareStatement
in interfacejava.sql.Connection
- Overrides:
prepareStatement
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
- Specified by:
prepareStatement
in interfacejava.sql.Connection
- Overrides:
prepareStatement
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException
- Specified by:
prepareStatement
in interfacejava.sql.Connection
- Overrides:
prepareStatement
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException
- Specified by:
prepareStatement
in interfacejava.sql.Connection
- Overrides:
prepareStatement
in classDelegatingConnection
- Throws:
java.sql.SQLException
-
getDelegate
public java.sql.Connection getDelegate()
Description copied from class:DelegatingConnection
Returns my underlyingConnection
.- Overrides:
getDelegate
in classDelegatingConnection
- Returns:
- my underlying
Connection
. - See Also:
DelegatingConnection.getDelegate()
-
getInnermostDelegate
public java.sql.Connection getInnermostDelegate()
Description copied from class:DelegatingConnection
If my underlyingConnection
is not a DelegatingConnection, returns it, otherwise recursively invokes this method on my delegate.Hence this method will return the first delegate that is not a DelegatingConnection, or null when no non-DelegatingConnection delegate can be found by traversing this chain.
This method is useful when you may have nested DelegatingConnections, and you want to make sure to obtain a "genuine"
Connection
.- Overrides:
getInnermostDelegate
in classDelegatingConnection
- See Also:
DelegatingConnection.getInnermostDelegate()
-
-