O'Reilly logo

Distributed Computing in Java 9 by Raja Malleswara Rao Pattamsetti

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

Sample program for the XA transaction

Let's now see a sample program that communicates with two Oracle database instances through an application with XA transaction.

The following is the series of steps to be executed by this program:

  1. Begin the transaction division on database DB1 and then on DB2.
  2. Perform a DML query execution on DB1 and then on DB2.
  3. Complete the transaction execution on DB1 and then on DB2.
  4. Prepare the completion on DB1 and then on DB2.
  5. Commit the transaction on DB1 and then on DB2.

The following is the program for XATransaction on two Oracle databases. Don't forget to include ojdbc.jar to your project when you are writing this example:

package distributedtransaction;//You need to import the java.sql package to use JDBC ...

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