Class ManagedDataSource<C extends java.sql.Connection>
- java.lang.Object
- 
- org.apache.tomcat.dbcp.dbcp2.PoolingDataSource<C>
- 
- org.apache.tomcat.dbcp.dbcp2.managed.ManagedDataSource<C>
 
 
- 
- Type Parameters:
- C- The kind of- Connectionto manage.
 - All Implemented Interfaces:
- java.lang.AutoCloseable,- java.sql.Wrapper,- javax.sql.CommonDataSource,- javax.sql.DataSource
 
 public class ManagedDataSource<C extends java.sql.Connection> extends PoolingDataSource<C> The ManagedDataSource is a PoolingDataSource that creates ManagedConnections.- Since:
- 2.0
 
- 
- 
Constructor SummaryConstructors Constructor Description ManagedDataSource(ObjectPool<C> pool, TransactionRegistry transactionRegistry)Creates a ManagedDataSource which obtains connections from the specified pool and manages them using the specified transaction registry.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description java.sql.ConnectiongetConnection()Returns aConnectionfrom my pool, according to the contract specified byObjectPool.borrowObject().TransactionRegistrygetTransactionRegistry()Gets the transaction registry.voidsetTransactionRegistry(TransactionRegistry transactionRegistry)Sets the transaction registry from the XAConnectionFactory used to create the pool.- 
Methods inherited from class org.apache.tomcat.dbcp.dbcp2.PoolingDataSourceclose, getConnection, getLoginTimeout, getLogWriter, getParentLogger, getPool, isAccessToUnderlyingConnectionAllowed, isWrapperFor, setAccessToUnderlyingConnectionAllowed, setLoginTimeout, setLogWriter, unwrap
 
- 
 
- 
- 
- 
Constructor Detail- 
ManagedDataSourcepublic ManagedDataSource(ObjectPool<C> pool, TransactionRegistry transactionRegistry) Creates a ManagedDataSource which obtains connections from the specified pool and manages them using the specified transaction registry. The TransactionRegistry must be the transaction registry obtained from the XAConnectionFactory used to create the connection pool. If not, an error will occur when attempting to use the connection in a global transaction because the XAResource object associated with the connection will be unavailable.- Parameters:
- pool- the connection pool
- transactionRegistry- the transaction registry obtained from the XAConnectionFactory used to create the connection pool object factory
 
 
- 
 - 
Method Detail- 
getConnectionpublic java.sql.Connection getConnection() throws java.sql.SQLExceptionDescription copied from class:PoolingDataSourceReturns aConnectionfrom my pool, according to the contract specified byObjectPool.borrowObject().- Specified by:
- getConnectionin interface- javax.sql.DataSource
- Overrides:
- getConnectionin class- PoolingDataSource<C extends java.sql.Connection>
- Throws:
- java.sql.SQLException
 
 - 
getTransactionRegistrypublic TransactionRegistry getTransactionRegistry() Gets the transaction registry.- Returns:
- The transaction registry.
- Since:
- 2.6.0
- See Also:
- setTransactionRegistry(TransactionRegistry)
 
 - 
setTransactionRegistrypublic void setTransactionRegistry(TransactionRegistry transactionRegistry) Sets the transaction registry from the XAConnectionFactory used to create the pool. The transaction registry can only be set once using either a connector or this setter method.- Parameters:
- transactionRegistry- the transaction registry acquired from the XAConnectionFactory used to create the pool
 
 
- 
 
-