This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JDBC and the fly likes How to handle transactions when two different databases are involved. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to handle transactions when two different databases are involved." Watch "How to handle transactions when two different databases are involved." New topic
Author

How to handle transactions when two different databases are involved.

NareshAnkuskani Kumar
Ranch Hand

Joined: Sep 15, 2005
Posts: 76
consider two tables namely Table-A and Table-B part of two different databases namely ORACLE and MYSQL.

Now the project requirement is updating the Table-A(ORACLE) and Table-B (MYSQL) as one transaction. i.e. either update both the tables or rollback both the tables.

Now my question is how could i handle this situation using JDBC(Type-4) driver.Because i think at a time only one JDBC driver can be loaded into the JVM.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

You need to look at JTA/JTS and distributed transactions. EJB containers tend to take care of this for us automagically.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
You need to use distributed (global) transactions. I have no idea if this is possible without an EJB server but, even if it is, this is one case where the set up and operation would be so much easier with such a server. An EJB server would, amongst other things, bootstrap the XA resources into a it's transaction manager, manage the connection pools via the data sources and manage the global transactions.

You will need to use XA drivers, XA-configured databases and data sources enabled for global transactions. Is there a suitable driver for MySQL?


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to handle transactions when two different databases are involved.
 
Similar Threads
i am using orcale, mysql databases , if i use context.xml i can get datasource for only one db
i am using orcale, mysql databases , if i use context.xml i can get datasource only for one db
Doubt regarding joins in SQL...
Comparing two tables of different database
Copy data from Oracle Database to Access Database in a servlet