user manual

Chapter 19: Transaction management 209
Handling of EJB exceptions
If a global transaction is associated with the current thread of execution do not
use this method. If the global transaction is not a container-managed
transaction, that is the application manages its own transactions, and a
commit is required use the JTA API to perform the commit rather than invoking
commit() directly on the JDBC connection.
Java.sql.Connection.rollback()
As defined in the JDBC API, this method rolls back all work that was
performed on a JDBC connection since the previous commit() or rollback(),
and releases all database locks.
If a global transaction is associated with the current thread of execution do not
use this method. If the global transaction is not a container-managed
transaction, that is the application manages its own transactions, and a
rollback is required use the JTA API to perform the rollback rather than
invoking rollback() directly on the JDBC connection.
Java.sql.Connection.close()
As defined in the JDBC API, this method closes the database connection and
all JDBC resources associated with the connection.
If the thread is associated with a transaction this call simply notifies the JDBC
pool that work on the connection is complete. The JDBC pool releases the
connection back to the connection pool once the transaction has completed.
JDBC connections opened by the JDBC pool cannot be closed explicitly by an
application.
Java.sql.Connection.setAutoCommit(boolean)
As defined in the JDBC API, this method is used to set the auto commit mode
of a transaction. The setAutoCommit() method allows Java applications to
either:
Execute and commit all SQL statements as individual transactions (when
set to true). This is the default mode, or
Explicitly invoke commit() or rollback() on the connection (when set to
false).
If the thread is associated with a transaction, the JDBC pool turns off the auto-
commit mode for all connections factoried in the scope of a partition's
transaction service transaction. This is because the transaction service must
control transaction completion. If an application is involved with a transaction,
and it attempts to set the auto commit mode to true, the
java.sql.SQLException() will be raised.
Handling of EJB exceptions
Enterprise JavaBeans can throw application and/or system level exceptions if
they encounter errors while handling transactions. Application-level
exceptions pertain to errors in the business logic and are intended to be
handled by the calling application. System-level exceptions, such as runtime