+

Search Tips   |   Advanced Search

Transaction type and connection behavior

All connection usage occurs within the scope of either a global transaction or a local transaction containment (LTC) boundary. Each transaction type places different requirements on connections and impacts connection settings differently.


Connection sharing and reuse

We can share connections within a global transaction scope (assuming other sharing rules are met). We can also share connections within a shareable LTC. We can serially reuse connections within an LTC scope. A get/use/close connection pattern followed by another instance of get/use/close (to the same data source or connection factory) enables you to reuse the same connection. See the topic, Unshareable and shareable connections for more details.


JDBC AutoCommit behavior

All JDBC connections, when first obtained through a getConnection() call, contain the setting AutoCommit = TRUE by default. However, different transaction scope and settings can result in changing, or simply overriding, the AutoCommit value.


One-phase commit and two-phase commit connections

The type and number of resource managers, such as a database server, that must be accessed by an application often determines the application transaction requirements. Consequently each type of resource manager places different requirements on connection behavior.

One-phase commit resources are such that work being done on a one phase connection cannot mix with other connections and ensure that the work done on all of the connections completes or fails atomically. The product does not allow more than one one-phase commit connection in a global transaction. Futhermore, it does not allow a one-phase commit connection in a global transaction with one or more two-phase commit connections. We can coordinate only multiple two-phase commit connections within a global transaction.

WebSphere Application Server provides last participant support, which enables a single one-phase commit resource to participate in a global transaction with one or more two-phase commit resources.

Note that any time that you do multiple getConnection() calls using a resource reference that specifies res-sharing-scope=Unshareable , you get multiple physical connections. This situation also occurs when res-sharing-scope=Shareable, but the sharing rules are broken. In either case, if you run in a global transaction, ensure the resources involved are enabled for two-phase commit (also sometimes referred to as JTA Enabled). Failure to do so results in an XA exception that logs the following message:


Related concepts

  • Data sources
  • Unshareable and shareable connections
  • Connection handles
  • Transaction support in WebSphere Application Server


    Related tasks

  • Use the transaction service