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 DBLinks and Two Phase Commit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "DBLinks and Two Phase Commit" Watch "DBLinks and Two Phase Commit" New topic

DBLinks and Two Phase Commit

Amber Vaidya
Ranch Hand

Joined: Oct 14, 2003
Posts: 42

I have a system that needs to update two databases (both Oracle 10g) in a single transaction.
The question is; if I create a DBLink between the two Oracle databases and treat this transaction as a normal transaction (not XA) would it work?

The system is a standalone java application (not deployed on any web/app server) and I am using Spring for JDBC.

If you think that the above approach will not work, can you please suggest an alternative?

Thanks in advance !!
Tim LeMaster
Ranch Hand

Joined: Aug 31, 2006
Posts: 226
Yes - Oracle - Ejb Transaction Across Database Links

This article is about EJBs but it applies because the transaction is done simply by using the same connection. So you could execute both statements and only call commit if they both succeed.

You could also do an XA transaction via JTA pretty easy in Spring via JBossTS.
I agree. Here's the link:
subject: DBLinks and Two Phase Commit
It's not a secret anymore!