Package org.apache.commons.dbcp2
Class PoolingDataSource.PoolGuardConnectionWrapper<D extends Connection>
java.lang.Object
org.apache.commons.dbcp2.AbandonedTrace
org.apache.commons.dbcp2.DelegatingConnection<D>
org.apache.commons.dbcp2.PoolingDataSource.PoolGuardConnectionWrapper<D>
- All Implemented Interfaces:
AutoCloseable,Connection,Wrapper,org.apache.commons.pool2.TrackedUse
- Enclosing class:
PoolingDataSource<C extends Connection>
private final class PoolingDataSource.PoolGuardConnectionWrapper<D extends Connection>
extends DelegatingConnection<D>
PoolGuardConnectionWrapper is a Connection wrapper that makes sure a closed connection cannot be used anymore.
- Since:
- 2.0
-
Field Summary
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the underlying connection, and close any Statements that were not explicitly closed.Returns my underlyingConnection.If my underlyingConnectionis not aDelegatingConnection, returns it, otherwise recursively invokes this method on my delegate.booleanisClosed()Methods inherited from class org.apache.commons.dbcp2.DelegatingConnection
abort, activate, checkOpen, clearCachedState, clearWarnings, closeInternal, commit, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStatement, createStatement, createStatement, createStruct, getAutoCommit, getCacheState, getCatalog, getClientInfo, getClientInfo, getDefaultQueryTimeout, getDefaultQueryTimeoutDuration, getDelegateInternal, getHoldability, getInnermostDelegateInternal, getMetaData, getNetworkTimeout, getSchema, getTransactionIsolation, getTypeMap, getWarnings, handleException, handleExceptionNoThrow, innermostDelegateEquals, isClosedInternal, isReadOnly, isValid, isValid, isWrapperFor, nativeSQL, passivate, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, rollback, setAutoCommit, setCacheState, setCatalog, setClientInfo, setClientInfo, setClosedInternal, setDefaultQueryTimeout, setDefaultQueryTimeout, setDelegate, setHoldability, setNetworkTimeout, setReadOnly, setSavepoint, setSavepoint, setSchema, setTransactionIsolation, setTypeMap, toString, unwrapMethods inherited from class org.apache.commons.dbcp2.AbandonedTrace
add, addTrace, clearTrace, close, getLastUsed, getLastUsedInstant, getTrace, removeThisTrace, removeTrace, setLastUsed, setLastUsed, setLastUsed
-
Constructor Details
-
PoolGuardConnectionWrapper
PoolGuardConnectionWrapper(D delegate)
-
-
Method Details
-
close
Description copied from class:DelegatingConnectionCloses the underlying connection, and close any Statements that were not explicitly closed. Sub-classes that override this method must:- Call
DelegatingConnection.passivate() - Call close (or the equivalent appropriate action) on the wrapped connection
- Set
closedtofalse
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceConnection- Overrides:
closein classDelegatingConnection<D extends Connection>- Throws:
SQLException- Ignored here, for subclasses.
- Call
-
getDelegate
Description copied from class:DelegatingConnectionReturns my underlyingConnection.- Overrides:
getDelegatein classDelegatingConnection<D extends Connection>- Returns:
- my underlying
Connection. - See Also:
-
getInnermostDelegate
Description copied from class:DelegatingConnectionIf my underlyingConnectionis not aDelegatingConnection, returns it, otherwise recursively invokes this method on my delegate.Hence this method will return the first delegate that is not a
DelegatingConnection, ornullwhen no non-DelegatingConnectiondelegate 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:
getInnermostDelegatein classDelegatingConnection<D extends Connection>- Returns:
- innermost delegate.
- See Also:
-
isClosed
- Specified by:
isClosedin interfaceConnection- Overrides:
isClosedin classDelegatingConnection<D extends Connection>- Throws:
SQLException
-