Distributed Transactions
A distributed
transaction
is a set of two or more individual
transactions, or branches, managed externally by a transaction
manager and committed or rolled back as a single, global transaction.
When it comes to distributed transactions, you have two choices of
how to implement them. If you need to implement a distributed
transaction between two or more Oracle databases, you can use
database links. When using database links, you act as though your
distributed transaction is just another local transaction and let
Oracle’s two-phase commit mechanism take care of the
distributed transaction process transparently. But what if you want
to manage a transaction between an Oracle and a Sybase database? Or
with a credit card processing center? For cases such as these, you
can use the JDBC 2.0 optional package’s
XAConnection
object instead of a standard
Connection
object.
Oracle’s XA functionality implements the JDBC 2.0 optional package’s support for distributed transactions. Although distributed transaction functionality is typically supported by an application server, such as one that supports Enterprise JavaBeans (EJB), this does not mean that you can’t take advantage of the XA infrastructure to manage your own distributed transactions.
To create an XAConnection
object, use an
XADataSource
. For the most part, Oracle’s
XADataSource
is configured just like, and
allocates connections just like, the DataSource
and ConnectionPoolDataSource
objects we covered in
Chapter ...
Get Java Programming with Oracle JDBC now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.