Oracle® C++ Call Interface Programmer's Guide, 11g Release 2 (11.2) E10764-04 |
|
|
PDF · Mobi · ePub |
The Oracle XA library is an external interface that allows transaction managers other than the Oracle server to coordinate global transactions. The XA library supports non-Oracle resource managers in distributed transactions. This is particularly useful in transactions between several databases and resources.
The implementation of the Oracle XA library conforms to the X/Open Distributed Transaction Processing (DTP) software architecture's XA interface specification. The Oracle XA Library is installed as part of the Oracle Database Enterprise Edition.
This chapter contains these topics:
See Also:
|
For connection, disconnection, and transaction control on Oracle databases, applications must interface with a transaction manager. OCCI has APIs for interacting with Environment
and Connection
objects within XA and make them available for Oracle database access, such as SELECT
queries, DML statements, object access, and so on.
Example 11-1 How to Use Transaction Managers with XA
/* Transaction manager opens connection to the Oracle server*/ tpopen("oracle_xa+acc=p/HR/password+sestm=10", 1, TMNOFLAGS); /* Transaction manager issues XA commands to start a global transaction*/ tpbegin(); /* Access the underlying Oracle database using OCCI */ Environment *xaenv = Environment::getXAEnvironment( "oracle_xa+acc=p/HR/password+sestm=10"); Connection *xaconn = xaenv->getXAConnection( "oracle_xa+acc=p/HR/password+sestm=10"); /* Use the Environment & Connection objects */ Statement *stmt = xaconn->createStatement( "Update Emp set sal = sal * 0.2"); ... /* Release the Environment & Connection objects */ xaenv->releaseXAConnection(xaconn); Environment::releaseXAEnvironment(xaenv);
The following methods of the Environment Class support use of XA libraries:
In addition, the getXAErrorCode() method of SQLException Class is necessary for XA enabled applications to determine if thrown exceptions are due to an SQL error (XA_OK
) or an XA error (an XA error code).