Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

JDBC Transactions involving more than one database?
Hi,

I'm building a data synchronization process that must be contained
within a transaction.  Tables from two different databases (Oracle and
Informix) will be updated during the process.  I'm thinking I can't do
this with JDBC type transactions since they are based on the Connect
type object and it can only handle transactions from one database
(unless they could be nested somehow?).

Would EJB transactions be the best way to go?  If so, please explain
why and how.....thnx!

Environment:
WebLogic 8.1 SP2
JRE 1.4.1
Oracle 9.2
Informix 9.3


Larry

Report this thread to moderator Post Follow-up to this message
Old Post
Larry
03-20-04 01:46 AM


Re: JDBC Transactions involving more than one database?
Hi!
Don't worry, you can use two or more transactional resources (two
database conenctions in your case) and roll back them all. Don´t nest
them, Weblogic will say commit or rollback to every TX resouce included
in your transaction.
I have not had any experience on threating two database connections but
I have had this managing one database and one JMS connection committing
or rolling back both.

Larry wrote:

> Hi,
>
> I'm building a data synchronization process that must be contained
> within a transaction.  Tables from two different databases (Oracle and
> Informix) will be updated during the process.  I'm thinking I can't do
> this with JDBC type transactions since they are based on the Connect
> type object and it can only handle transactions from one database
> (unless they could be nested somehow?).
>
> Would EJB transactions be the best way to go?  If so, please explain
> why and how.....thnx!
>
> Environment:
> WebLogic 8.1 SP2
> JRE 1.4.1
> Oracle 9.2
> Informix 9.3
>
>
> Larry


Report this thread to moderator Post Follow-up to this message
Old Post
Víctor
03-20-04 01:46 AM


Re: JDBC Transactions involving more than one database?
"Larry" <larry.brown@bankofamerica.com> wrote in message
news:2686e6da.0403040704.4e1a96ea@posting.google.com...
> Hi,
>
> I'm building a data synchronization process that must be contained
> within a transaction.  Tables from two different databases (Oracle and
> Informix) will be updated during the process.  I'm thinking I can't do
> this with JDBC type transactions since they are based on the Connect
> type object and it can only handle transactions from one database
> (unless they could be nested somehow?).
>
> Would EJB transactions be the best way to go?  If so, please explain
> why and how.....thnx!
>
> Environment:
> WebLogic 8.1 SP2
> JRE 1.4.1
> Oracle 9.2
> Informix 9.3
>
>
> Larry

I've had experience with this--ported 40,000 records from one database (and
format) into another.

All you have to do is get two connections (conn1 and conn2, one for each
database), and simply do the reading/writing in-between.

Something along these lines:

ResultSet rs1 = conn1.executeQuery(sqlString1);
PreparedStatement stmt =  conn2.prepareStatement(sqlString2);
while (rs.next()) {

stmt.setInt(1, rs.getInt(1));
//repeat as necessary, getting integers, doubles, Strings, booleans, etc

stmt.addBatch(); //suggest using batch updates for larger transactions
}
int i = stmt.executeUpdate();


Just don't forget to close your connections, catch Exceptions, etc...typical
cleaning up.

Hope this helps--worked fine for me.

As an aside, I created a couple of beans to handle "translating" the data
from one format into another...worked pretty good.

Let us know how it turns out.

Happyslayer



Report this thread to moderator Post Follow-up to this message
Old Post
Happyslayer
03-20-04 01:46 AM


Re: JDBC Transactions involving more than one database?
Thnx for the feedback....I do have a little experience with EJB's, but it
doesn't look like I have to go there.

"Larry" <larry.brown@bankofamerica.com> wrote in message
news:2686e6da.0403040704.4e1a96ea@posting.google.com...
> Hi,
>
> I'm building a data synchronization process that must be contained
> within a transaction.  Tables from two different databases (Oracle and
> Informix) will be updated during the process.  I'm thinking I can't do
> this with JDBC type transactions since they are based on the Connect
> type object and it can only handle transactions from one database
> (unless they could be nested somehow?).
>
> Would EJB transactions be the best way to go?  If so, please explain
> why and how.....thnx!
>
> Environment:
> WebLogic 8.1 SP2
> JRE 1.4.1
> Oracle 9.2
> Informix 9.3
>
>
> Larry



Report this thread to moderator Post Follow-up to this message
Old Post
Larry
03-20-04 01:46 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Beans archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 12:53 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.