C - the Connection typepublic class ManagedConnection<C extends Connection> extends DelegatingConnection<C>
When enlisted in a transaction the setAutoCommit(), commit(), rollback(), and setReadOnly() methods throw a SQLException. This is necessary to assure that the transaction completes as a single unit.
| Modifier and Type | Class and Description | 
|---|---|
| protected class  | ManagedConnection.CompletionListenerDelegates to  transactionComplete()for transaction completion events. | 
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE| Constructor and Description | 
|---|
| ManagedConnection(ObjectPool<C> pool,
                 TransactionRegistry transactionRegistry,
                 boolean accessToUnderlyingConnectionAllowed)Constructs a new instance responsible for managing a database connection in a transactional environment. | 
| Modifier and Type | Method and Description | 
|---|---|
| protected void | checkOpen() | 
| void | close()Closes the underlying connection, and close any Statements that were not explicitly closed. | 
| void | commit() | 
| C | getDelegate()Returns my underlying  Connection. | 
| Connection | getInnermostDelegate()If my underlying  Connectionis not aDelegatingConnection, returns it, otherwise recursively
 invokes this method on my delegate. | 
| boolean | isAccessToUnderlyingConnectionAllowed()If false, getDelegate() and getInnermostDelegate() will return null. | 
| void | rollback() | 
| void | setAutoCommit(boolean autoCommit) | 
| void | setReadOnly(boolean readOnly) | 
| protected void | transactionComplete() | 
abort, activate, clearCachedState, clearWarnings, closeInternal, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStatement, createStatement, createStatement, createStruct, getAutoCommit, getCacheState, getCatalog, getClientInfo, getClientInfo, getDefaultQueryTimeout, getDelegateInternal, getHoldability, getInnermostDelegateInternal, getMetaData, getNetworkTimeout, getSchema, getTransactionIsolation, getTypeMap, getWarnings, handleException, innermostDelegateEquals, isClosed, isClosedInternal, isReadOnly, isValid, isWrapperFor, nativeSQL, passivate, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, setCacheState, setCatalog, setClientInfo, setClientInfo, setClosedInternal, setDefaultQueryTimeout, setDelegate, setHoldability, setNetworkTimeout, setSavepoint, setSavepoint, setSchema, setTransactionIsolation, setTypeMap, toString, unwrapaddTrace, clearTrace, getLastUsed, getTrace, removeTrace, setLastUsed, setLastUsedpublic ManagedConnection(ObjectPool<C> pool, TransactionRegistry transactionRegistry, boolean accessToUnderlyingConnectionAllowed) throws SQLException
pool - The connection pool.transactionRegistry - The transaction registry.accessToUnderlyingConnectionAllowed - Whether or not to allow access to the underlying Connection.SQLException - Thrown when there is problem managing transactions.protected void checkOpen()
                  throws SQLException
checkOpen in class DelegatingConnection<C extends Connection>SQLExceptionpublic void close()
           throws SQLException
DelegatingConnectionfalseclose in interface AutoCloseableclose in interface Connectionclose in class DelegatingConnection<C extends Connection>SQLExceptionprotected void transactionComplete()
public void setAutoCommit(boolean autoCommit)
                   throws SQLException
setAutoCommit in interface ConnectionsetAutoCommit in class DelegatingConnection<C extends Connection>SQLExceptionpublic void commit()
            throws SQLException
commit in interface Connectioncommit in class DelegatingConnection<C extends Connection>SQLExceptionpublic void rollback()
              throws SQLException
rollback in interface Connectionrollback in class DelegatingConnection<C extends Connection>SQLExceptionpublic void setReadOnly(boolean readOnly)
                 throws SQLException
setReadOnly in interface ConnectionsetReadOnly in class DelegatingConnection<C extends Connection>SQLExceptionpublic boolean isAccessToUnderlyingConnectionAllowed()
public C getDelegate()
DelegatingConnectionConnection.getDelegate in class DelegatingConnection<C extends Connection>Connection.public Connection getInnermostDelegate()
DelegatingConnectionConnection 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.
 
getInnermostDelegate in class DelegatingConnection<C extends Connection>Copyright © 2001–2018 The Apache Software Foundation. All rights reserved.