Connections and transactions

All connection usage occurs within the scope of either a global transaction or a local transaction containment (LTC).

Connection behavior depends on your current operating scope. This topic discusses some of the common characteristics you see when using connections in one of the transaction scopes of WebSphere Application Server - Express.

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

JDBC AutoCommit behavior

All JDBC connections, when first obtained through a getConnection call, have AutoCommit set to "true" by default.

One phase commit and two phase commit resources

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. Additionally, the product does not allow a one phase commit connection in a global transaction with one or more two phase commit connections. You can coordinate only multiple two phase commit connections within a global transaction.

Note that any time you do multiple getConnection() calls using a resource reference that specifies res-sharing-scope=Unshareable, then 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 XAException that logs the following message: WTRN0063E: An illegal attempt to enlist a one phase capable resource with existing two phase capable resources has occurred.