PDA

View Full Version : J2EE without EJB & transaction



snpe
Sep 22nd, 2004, 06:59 AM
Hello,
I read J2EE without EJB.In chapter 9 (transaction) is assert :
When we request distributed database , we have to use JTA

It isn't complete correct.
With Oracle (> ver 7) we have distributed transaction and 2pc with simple JDBC (and any client)
We havn't to have Oracle RAC - it exists in standard database, RAC isn't for distributed transaction - it is if more processes (processors) access to one databases - cluster or parallel access

For example :

database1 have table 1
database2 have table2

We can make database link on database1 on table2 on database2 and transaction is :

connect to database1
begin transaction
update table1
update table2@database
commit

For distributed transaction in Jva we have to have only simple JDBC (or for instance hibernate wthout JTA)

We can make synonym on database1 to table2 on database2 and access to tables is transparent - we haven't to know where is table and transaction can be like :

connect to database1
begin transaction
update table1
update table2
commit

table1 and table2 are on differnet database (can be different computers) and transaction is distributed without J2ee server - oracle do distributed work for us)

regards

Rod Johnson
Sep 22nd, 2004, 08:09 AM
Good point.

trisberg
Sep 22nd, 2004, 09:22 AM
It is a valid point - you can have distributed transactions without using JTA. In this case you are using Oracle's built in transaction manager behind the scenes.

However, from the Java application perspective, it looks like a single database with a single connection that just happens to have a transaction manager running within the database environment. The Java application is not using a distributed database transaction directly, so no need for JTA here.

snpe
Sep 22nd, 2004, 10:54 AM
I talked this to hibernate forum/team and they didn't agree with me

I think that it is valid for any database with two phase commit - it be great that postgresql have this features, but oracle is 150$/user now (standard edition)

regards