Package org.apache.commons.dbcp.managed
Class ManagedDataSource
java.lang.Object
org.apache.commons.dbcp.PoolingDataSource
org.apache.commons.dbcp.managed.ManagedDataSource
- All Implemented Interfaces:
Wrapper
,CommonDataSource
,DataSource
The ManagedDataSource is a PoolingDataSource that creates ManagedConnections.
- Version:
- $Revision$
- Author:
- Dain Sundstrom
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an uninitialized datasource.ManagedDataSource
(org.apache.commons.pool.ObjectPool pool, TransactionRegistry transactionRegistry) Creates a ManagedDataSource which obtains connections from the specified pool and manages them using the specified transaction registry. -
Method Summary
Modifier and TypeMethodDescriptionReturn aConnection
from my pool, according to the contract specified byObjectPool.borrowObject()
.void
setTransactionRegistry
(TransactionRegistry transactionRegistry) Sets the transaction registry from the XAConnectionFactory used to create the pool.Methods inherited from class org.apache.commons.dbcp.PoolingDataSource
getConnection, getLoginTimeout, getLogWriter, getParentLogger, isAccessToUnderlyingConnectionAllowed, isWrapperFor, setAccessToUnderlyingConnectionAllowed, setLoginTimeout, setLogWriter, setPool, unwrap
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder
-
Constructor Details
-
ManagedDataSource
public ManagedDataSource()Creates an uninitialized datasource. Before this data source can be used a pool and transaction registry must be set. -
ManagedDataSource
public ManagedDataSource(org.apache.commons.pool.ObjectPool 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 occure 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 pooltransactionRegistry
- the transaction registry obtained from the XAConnectionFactory used to create the connection pool object factory
-
-
Method Details
-
setTransactionRegistry
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
-
getConnection
Description copied from class:PoolingDataSource
Return aConnection
from my pool, according to the contract specified byObjectPool.borrowObject()
.- Specified by:
getConnection
in interfaceDataSource
- Overrides:
getConnection
in classPoolingDataSource
- Throws:
SQLException
-