3.15.8 Transaction timeout and statement cancellation

The transaction timeout functionality monitors the time elapsed since the transaction was started, and rolls back the transaction when the specified time has lapsed. The monitoring time is from the completion of transaction startup until the start of transaction conclusion. After the transaction times out, the access to the JTA and the JDBC interface in the applicable transaction reports an exception.

The transaction timeout functionality is enabled for the Application Server-managed transactions.

Note that after a transaction times out in the BMT, servlets, or JSPs, if you issue UserTransaction.commit/rollback for the applicable transaction, you can access the JTA and JDBC interface.

#: Whether a timeout has occurred is checked every second; therefore, a calculation error of a maximum of one second occurs for the time set up as a transaction timeout.

Organization of this subsection
(1) Transaction timeout settings
(2) Statement cancellation when a transaction timeout occurs

(1) Transaction timeout settings

You can specify the transaction timeout settings for the J2EE servers, UserTransaction interface, or CMT attribute of the EJB.

(a) Settings for the J2EE servers

You specify the transaction timeout settings for the J2EE servers by customizing the J2EE server properties. For details on customizing the settings for the J2EE server operations, see 3.15.13 Settings in the execution environment.

(b) Settings for the UserTransaction interface

Use the setTransactionTimeout method of the UserTransaction interface to change the default values.

(c) Settings for the CMT attribute of the EJB

Use the server management commands to specify the settings for the CMT attribute of the EJB. You can choose to specify the settings for Beans, interfaces, and methods.

The settings are enabled for one of the following methods:

The timeout settings are disabled for the Supports attribute and Mandatory attribute operating in the transaction propagated from the client and for the NotSupported attribute and Never attribute that do not use transactions. For details on the transaction attributes, see 2.7.3 CMT in the uCosminexus Application Server EJB Container Functionality Guide.

Note that the priority order of the settings is as follows:

  1. Settings for methods
  2. Settings for interfaces
  3. Settings for Beans
  4. Settings for J2EE servers

You specify the transaction timeout settings for Beans as the attributes (properties) of the Session Bean, Entity Bean, or Message-driven Bean included in the J2EE application. For details on the J2EE application settings, see 3.15.13 Settings in the execution environment.

(2) Statement cancellation when a transaction timeout occurs

If a transaction times out when the SQL statement being executed has not returned, the statement is cancelled.

To enable statement cancellation, you must specify true in the CancelStatement property of DB Connector. For details on the resource adapter settings, see 3.15.13 Settings in the execution environment.