O'Reilly logo

Java Programming with Oracle JDBC by Donald Bales

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required