Package org.apache.commons.dbcp.managed
Class DataSourceXAConnectionFactory
- java.lang.Object
-
- org.apache.commons.dbcp.managed.DataSourceXAConnectionFactory
-
- All Implemented Interfaces:
ConnectionFactory
,XAConnectionFactory
public class DataSourceXAConnectionFactory extends java.lang.Object implements XAConnectionFactory
An implementation of XAConnectionFactory which uses a real XADataSource to obtain connections and XAResources.- Version:
- $Revision$
- Author:
- Dain Sundstrom
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
password
protected TransactionRegistry
transactionRegistry
protected java.lang.String
username
protected javax.sql.XADataSource
xaDataSource
-
Constructor Summary
Constructors Constructor Description DataSourceXAConnectionFactory(javax.transaction.TransactionManager transactionManager, javax.sql.XADataSource xaDataSource)
Creates an DataSourceXAConnectionFactory which uses the specified XADataSource to create database connections.DataSourceXAConnectionFactory(javax.transaction.TransactionManager transactionManager, javax.sql.XADataSource xaDataSource, java.lang.String username, java.lang.String password)
Creates an DataSourceXAConnectionFactory which uses the specified XADataSource to create database connections.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.sql.Connection
createConnection()
Create a newConnection
in an implementation specific fashion.TransactionRegistry
getTransactionRegistry()
Gets the TransactionRegistry for this connection factory which contains a the XAResource for every connection created by this factory.java.lang.String
getUsername()
Gets the username used to authenticate new connections.void
setPassword(java.lang.String password)
Sets the password used to authenticate new connections.void
setUsername(java.lang.String username)
Sets the username used to authenticate new connections.
-
-
-
Field Detail
-
transactionRegistry
protected TransactionRegistry transactionRegistry
-
xaDataSource
protected javax.sql.XADataSource xaDataSource
-
username
protected java.lang.String username
-
password
protected java.lang.String password
-
-
Constructor Detail
-
DataSourceXAConnectionFactory
public DataSourceXAConnectionFactory(javax.transaction.TransactionManager transactionManager, javax.sql.XADataSource xaDataSource)
Creates an DataSourceXAConnectionFactory which uses the specified XADataSource to create database connections. The connections are enlisted into transactions using the specified transaction manager.- Parameters:
transactionManager
- the transaction manager in which connections will be enlistedxaDataSource
- the data source from which connections will be retrieved
-
DataSourceXAConnectionFactory
public DataSourceXAConnectionFactory(javax.transaction.TransactionManager transactionManager, javax.sql.XADataSource xaDataSource, java.lang.String username, java.lang.String password)
Creates an DataSourceXAConnectionFactory which uses the specified XADataSource to create database connections. The connections are enlisted into transactions using the specified transaction manager.- Parameters:
transactionManager
- the transaction manager in which connections will be enlistedxaDataSource
- the data source from which connections will be retrievedusername
- the username used for authenticating new connections or null for unauthenticatedpassword
- the password used for authenticating new connections
-
-
Method Detail
-
getUsername
public java.lang.String getUsername()
Gets the username used to authenticate new connections.- Returns:
- the user name or null if unauthenticated connections are used
-
setUsername
public void setUsername(java.lang.String username)
Sets the username used to authenticate new connections.- Parameters:
username
- the username used for authenticating the connection or null for unauthenticated
-
setPassword
public void setPassword(java.lang.String password)
Sets the password used to authenticate new connections.- Parameters:
password
- the password used for authenticating the connection or null for unauthenticated
-
getTransactionRegistry
public TransactionRegistry getTransactionRegistry()
Description copied from interface:XAConnectionFactory
Gets the TransactionRegistry for this connection factory which contains a the XAResource for every connection created by this factory.- Specified by:
getTransactionRegistry
in interfaceXAConnectionFactory
- Returns:
- the transaction registry for this connection factory
-
createConnection
public java.sql.Connection createConnection() throws java.sql.SQLException
Description copied from interface:XAConnectionFactory
Create a newConnection
in an implementation specific fashion. An implementation can assume that the caller of this will wrap the connection in a proxy that protects access to the setAutoCommit, commit and rollback when enrolled in a XA transaction.- Specified by:
createConnection
in interfaceConnectionFactory
- Specified by:
createConnection
in interfaceXAConnectionFactory
- Returns:
- a new
Connection
- Throws:
java.sql.SQLException
- if a database error occurs creating the connection
-
-