solidDB Help : Samples : Distributed transactions with Java Transaction API sample
  
Distributed transactions with Java Transaction API sample
The sample demonstrates how to use the XA interface that is provided by the Java Transaction API (JTA). XA enables solidDB to participate in distributed transactions that are coordinated by an external transaction manager by using the two-phase commit protocol.
The sample program plays the role of both an application and a transaction manager. The application demonstrates the use of an XA interface to manage (prepare and commit) a distributed transaction that is executed against two instances of the solidDB server.
The files for the sample are located in the soliddb-installdir\samples\jta directory.
Note To run the sample, you must install JDK 1.7 or later and set the PATH and CLASSPATH settings for the Java compiler.
For general information about running the samples, see Samples.
The sample application (JTASample.java) completes the following steps:
1 Connect to two servers and create an empty table on each server.
2 Execute an distributed transaction that adds two rows to the table in each server (the rows are not immediately visible because the transaction is not committed).
3 Execute two separate non-distributed transactions (the first inserts a row in the table on one server and the second inserts a row in the table on the other server), and commit the transaction (the rows from the transactions are visible but the rows from the distributed transaction are not).
4 Prepare and commit the sub-transactions of the distributed transaction (the rows added by the distributed transaction are now visible).
Running the sample
Run the runme script (runme.bat in Windows), which compiles the application, starts two servers, and runs the application.
Go up to
Samples