JDBC and transactions
The transaction scopes in Transactions map to the following JDBC modes:
- Command
-
Connection autoCommit property set to true.
- Local
-
Connection autoCommit property set to false. The transaction is committed by setting autoCommit to true or calling
java.sql.Connection.commit
. The transaction can be rolled back by a call tojava.sql.Connection.rollback
- Global
-
The XAResource interface provided by an XAConnection is used to control the transaction. Note that XAConnections are available only if Teiid Spring Boot is consumed through its XADataSource,
org.teiid.jdbc.TeiidDataSource
. JEE containers or data access APIs typically control XA transactions on behalf of application code.
J2EE provides the following ways to manage transactions for beans:
- Client-controlled
-
The client of a bean begins and ends a transaction explicitly.
- Bean-managed
-
The bean itself begins and ends a transaction explicitly.
- Container-managed
-
The application server container begins and ends a transaction automatically.
In any of the preceding cases, transactions can be either local or XA transactions, depending on how the code and descriptors are written. The XA specification does not require some types of beans (for example, stateful session beans and entity beans) to work with non-transactional sources. However, according to the specification, optionally, application servers can allow the use of these beans with non-transactional sources, with the caution that such usage is not portable or predictable. Generally speaking, to provide for most types of EJB activities in a portable fashion, applications require a mechanism for managing transactions.