Scalable Database Server, HiRDB Version 8 UAP Development Guide

[Contents][Index][Back][Next]

16.4.3 Distributed transactions

In the JDBC2.0 Optional Package, distributed transactions in cooperation with the transaction manager (TM) based on the XA standard of X/Open are defined as an extension of the connection pooling function. The following provides an overview of distributed transactions:

As with connection pooling, Connection objects used by applications are generated by the XAConnection class. However, there are certain differences compared with the Connection objects generated by the DataSource class provided by the PooledConnection class or JDBC driver.

Table 16-12 lists the classes related to distributed transactions.

Table 16-12 Classes related to distributed transactions

Class Overview
javax.sql.DataSource
  • Provided by a transaction linkage function.
  • Used as the interface to applications during database connection.
  • Normally, linkage to a TM and connection pools are controlled in this class.
  • Normally, registered in JNDI for use.
  • Different from the DataSource class provided by the JDBC driver.
javax.sql.XADataSource
  • Provided by the JDBC driver.
  • Can use a method for setting/acquiring connection information necessary for database connection.
  • Normally not used directly from an application, and is used by a transaction linkage function.
  • Normally, registered in JNDI for use.
  • A transaction linkage function acquires an XAConnection object from this class of objects.
javax.sql.XAConnection
  • Provided by the JDBC driver.
  • This is a subclass of the PooledConnection class. That is, it inherits all methods related to connection pooling.
  • Normally not used directly from an application, and is used by a transaction linkage function.
  • A transaction linkage function targets this class of objects for pooling.
  • A transaction linkage function acquires a Connection object to be used by an application from this class of objects.
javax.sql.ConnectionEventListener
  • Provided by a transaction linkage function.
  • A transaction linkage function senses a connection pooling trigger by detecting a disconnection or SQL error through this class of objects.
javax.transaction.xa.XAResource
  • Provided by the JDBC driver.
  • Can use the XA-related methods used by a TM.
javax.transaction.xa.Xid
  • Provided by the JDBC driver and TM.
  • Used as the argument/return value of an XAResource class method.

Because the interface definition of the classes listed in Table 16-12 is not included in JDK as a standard feature, you must acquire them from the JavaSoft website when you develop a transaction linkage facility.

The following are the package names and class names of the classes provided by the JDBC driver and shown in Table 16-12.

Package name: JP.co.Hitachi.soft.HiRDB.JDBC

XADataSource class name: JdbhXADataSource

XAConnection class name: JdbhXAConnection

XAResource class name: JdbhXAResource

Xid class name: JdbhXid

Note that the setting of the connection information of the XADataSource class provided by the JDBC driver is the same as the setting of the connection information of the DataSource class provided by the JDBC driver.