Search code examples
mysqlsql-serverjdbcxa

Using XA transaction with JDBC, MySQL, and Microsoft SQL Server


Suppose I have MySQL server running on one machine, a Microsoft SQL Server running on a second machine, and my own custom Java database running on a third machine.

How do I use the X/Open XA standard to run a distributed transaction across all three?

Does X/Open XA specify a protocol layered over TCP or UDP? I could not find any information on this. XA appears to not specify anything about networking in which case how can it be used to run a distributed transaction across MySQL, SQL Server, and a custom Java database.


Solution

  • It is on the database to provide support for 2 phase commit transactions. In general they provide a different implementation of their ConnectionPool. If your Java application runs on an application server you must explicitly define an XA DataSource.

    XA does not need to specify any low level network requirements. It's an application protocol, WikiPedia provides a nice overview: http://en.wikipedia.org/wiki/2PC

    So, if you want to implement a distributed connection, all participants must provide an XA capable interface.