Oracle® C++ Call Interface Programmer's Guide 10g Release 1 (10.1) Part Number B10778-01 |
|
|
View PDF |
The Oracle XA library is an external interface that allows transaction managers other than the Oracle server to coordinate global transactions. XA library use 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 9-1 How to Use Transaction Managers with XA
/* Transaction manager opens connection to the Oracle server*/ tpopen("oracle_xa+acc=p/SCOTT/TIGER+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/SCOTT/TIGER+sestm=10"); Connection *xaconn = xaenv->getXAConnection( "oracle_xa+acc=p/SCOTT/TIGER+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 should be used by XA enabled applications to determine if thrown exceptions are due to an SQL error (XA_OK
) or an XA error (an XA error code).