JDBC and transactions
The transaction scopes in Transaction support 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 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 these cases, transactions may be either local or XA transactions, depending on how the code and descriptors are written. Some kinds of beans (stateful session beans and entity beans) are not required by the specification to support non-transactional sources, although the specification does allow an application server to optionally support this with the caution that this is not portable or predictable. Generally speaking, to support most typical EJB activities in a portable fashion requires some kind of transaction support.