Class LocalXAConnectionFactory
java.lang.Object
org.apache.tomcat.dbcp.dbcp2.managed.LocalXAConnectionFactory
- All Implemented Interfaces:
ConnectionFactory,XAConnectionFactory
An implementation of XAConnectionFactory which manages non-XA connections in XA transactions. A non-XA connection
commits and rolls back as part of the XA transaction, but is not recoverable since the connection does not implement
the 2-phase protocol.
- Since:
- 2.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classLocalXAResource is a fake XAResource for non-XA connections. -
Constructor Summary
ConstructorsConstructorDescriptionLocalXAConnectionFactory(jakarta.transaction.TransactionManager transactionManager, jakarta.transaction.TransactionSynchronizationRegistry transactionSynchronizationRegistry, ConnectionFactory connectionFactory) Creates an LocalXAConnectionFactory which uses the specified connection factory to create database connections.LocalXAConnectionFactory(jakarta.transaction.TransactionManager transactionManager, ConnectionFactory connectionFactory) Creates an LocalXAConnectionFactory which uses the specified connection factory to create database connections. -
Method Summary
Modifier and TypeMethodDescriptionCreates a newConnectionin an implementation specific fashion.Gets the connection factory.Gets the transaction registry.
-
Constructor Details
-
LocalXAConnectionFactory
public LocalXAConnectionFactory(jakarta.transaction.TransactionManager transactionManager, ConnectionFactory connectionFactory) Creates an LocalXAConnectionFactory which uses the specified connection factory 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 enlistedconnectionFactory- the connection factory from which connections will be retrieved
-
LocalXAConnectionFactory
public LocalXAConnectionFactory(jakarta.transaction.TransactionManager transactionManager, jakarta.transaction.TransactionSynchronizationRegistry transactionSynchronizationRegistry, ConnectionFactory connectionFactory) Creates an LocalXAConnectionFactory which uses the specified connection factory 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 enlistedtransactionSynchronizationRegistry- the optional TSR to register synchronizations withconnectionFactory- the connection factory from which connections will be retrieved- Since:
- 2.8.0
-
-
Method Details
-
createConnection
Description copied from interface:XAConnectionFactoryCreates a newConnectionin 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:
createConnectionin interfaceConnectionFactory- Specified by:
createConnectionin interfaceXAConnectionFactory- Returns:
- a new
Connection - Throws:
SQLException- if a database error occurs creating the connection
-
getConnectionFactory
Gets the connection factory.- Returns:
- The connection factory.
- Since:
- 2.6.0
-
getTransactionRegistry
Gets the transaction registry.- Specified by:
getTransactionRegistryin interfaceXAConnectionFactory- Returns:
- The transaction registry.
-