File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Distributed Transactions in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Distributed Transactions in Java" Watch "Distributed Transactions in Java" New topic

Distributed Transactions in Java

jim jjoh

Joined: May 02, 2011
Posts: 7

I have to do operations in 3 different schema from my application.
I am using Jboss as my application server.
Can you suggest a best way to handle transactions.
I have some theoretical knowledge about 2 phase commit.

Can anyone provide a solution.

Martin Vajsar

Joined: Aug 22, 2010
Posts: 3729

If all three schemas reside in the same database, you might be able (depending on the database) to grant necessary permissions and access all the schemas from a single connection. This way would seem the best to me, as you could completely avoid distributed transactions.

If this is not possible, you'd probably need to use a transaction manager that would coordinate distributed transactions. The details of two-phase commits would be managed by it. To the best of my understanding, most application servers have such a transaction manager. I have no direct experience, but googling up transaction manager jboss brings up this.
Pat Farrell

Joined: Aug 11, 2007
Posts: 4659

jim jjoh wrote:I have some theoretical knowledge about 2 phase commit.

Do you have any practical experience with usage of 2 phase commit?

In my experience, it rarely works as you wish. Its more a theoretical solution than a real one.
I agree. Here's the link:
subject: Distributed Transactions in Java
It's not a secret anymore!