ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzatz_5.4.0.1/51/program/datacntr.htm

41 lines
4.2 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK rel="stylesheet" type="text/css" href="../../../rzahg/ic.css">
<title>Connections and transactions</title>
</head>
<BODY>
<!-- Java sync-link -->
<SCRIPT LANGUAGE="Javascript" SRC="../../../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
<h6><a name="datacntr"></a>Connections and transactions</h6>
<p>All connection usage occurs within the scope of either a global transaction or a local transaction containment (LTC).</p>
<p>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.</p>
<p>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 <a href="datashre.htm">Unshareable and shareable connections</a> for more details.</p>
<p><strong>JDBC AutoCommit behavior</strong></p>
<p>All JDBC connections, when first obtained through a getConnection call, have AutoCommit set to &quot;true&quot; by default.</p>
<ul>
<li><p>If you operate within an LTC and have its resolution-control set to Application, then AutoCommit remains TRUE unless changed by the application.</p></li>
<li><p>If you operate within an LTC and have its resolution-control set to ContainerAtBoundary, then the application should not touch the AutoCommit setting. The WebSphere Application Server - Express run time sets the AutoCommit value to FALSE before work begins, then commits or rolls back the work as appropriate at the end of the LTC scope.</p></li>
<li><p>If you use a connection within a global transaction, then regardless of the user changing the AutoCommit setting, upon first use of the connection to do work the database ignores the AutoCommit setting so that the transaction service that controls the commit and rollback processing can manage the transaction. After the transaction completes, the AutoCommit value returns to the value it had before the first use of the connection. So even if the AutoCommit value is set to TRUE before the connection is used in a global transaction, you need not set the value to FALSE since the value is ignored by the database. In this example, after the transaction completes, the AutoCommit value of the connection returns to TRUE.</p></li>
<li><p>If you use multiple distinct connections within a global transaction, all work is guaranteed to commit or roll back together. This is not the case for a local transaction containment (LTC scope). Within an LTC, work done on one connection commits or rolls back independently from work done on any other connection within the LTC.</p></li>
</ul>
<p><strong>One phase commit and two phase commit resources</strong></p>
<p>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.</p>
<p>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.</p>
</body>
</html>