EasyManuals Logo

IBM DB2 User Manual

IBM DB2
585 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #484 background imageLoading...
Page #484 background image
SYSIBM.INDOUBT table and the T4XAIndbtPkg package. You should never
modify the SYSIBM.INDOUBT table manually.
In JDBC or SQLJ applications, distributed transactions are supported for
connections that are established using the DataSource interface. A connection is
normally established by the application server.
Related concepts
Chapter 13, “JDBC and SQLJ global transaction support,” on page 473
Related reference
“DB2T4XAIndoubtUtil for distributed transactions with DB2 UDB for OS/390
and z/OS Version 7 servers” on page 428
Example of a distributed transaction that uses JTA methods
Distributed transactions typically involve multiple connections to the same data
source or different data sources, which can include data sources from different
manufacturers.
The best way to demonstrate distributed transactions is to contrast them with local
transactions. With local transactions, a JDBC application makes changes to a
database permanent and indicates the end of a unit of work in one of the
following ways:
v By calling the Connection.commit or Connection.rollback methods after
executing one or more SQL statements
v By calling the Connection.setAutoCommit(true) method at the beginning of the
application to commit changes after every SQL statement
Figure 56 outlines code that executes local transactions.
In contrast, applications that participate in distributed transactions cannot call the
Connection.commit, Connection.rollback,orConnection.setAutoCommit(true)
methods within the distributed transaction. With distributed transactions, the
Connection.commit or Connection.rollback methods do not indicate transaction
boundaries. Instead, your applications let the application server manage
transaction boundaries.
Figure 57 on page 469 demonstrates an application that uses distributed
transactions. While the code in the example is running, the application server is
also executing other EJBs that are part of this same distributed transaction. When
all EJBs have called utx.commit(), the entire distributed transaction is committed
by the application server. If any of the EJBs are unsuccessful, the application server
rolls back all the work done by all EJBs that are associated with the distributed
con1.setAutoCommit(false); // Set autocommit off
// execute some SQL
...
con1.commit(); // Commit the transaction
// execute some more SQL
...
con1.rollback(); // Roll back the transaction
con1.setAutoCommit(true); // Enable commit after every SQL statement
...
// Execute some more SQL, which is automatically committed after
// every SQL statement.
Figure 56. Example of a local transaction
468 Application Programming Guide and Reference for Java

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the IBM DB2 and is the answer not in the manual?

IBM DB2 Specifications

General IconGeneral
DeveloperIBM
Initial Release1983
LicenseProprietary
Written inC, C++
CategoryDatabase Management System (RDBMS)
Operating SystemLinux, Windows
Programming LanguagesC, C++
Data ModelsRelational
EditionsCommunity, Standard, Advanced
Key Featureshigh availability, scalability