aspose file tools
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes transaction in ejb vs jdbc Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Reply Bookmark "transaction in ejb vs jdbc" Watch "transaction in ejb vs jdbc" New topic
Author

transaction in ejb vs jdbc

tom walters
Ranch Hand

Joined: Feb 14, 2002
Posts: 34
a guideline is to use ejb if you are using transactions but i could do transactions without ejb by just using jdbc. what is the difference?
are they the same when i connect to just one transaction aware system (such as an oracle database)?
does the difference come into play when i want a transaction to span multiple transaction aware systems like oracle and db2?
Rufus BugleWeed
Ranch Hand

Joined: Feb 22, 2002
Posts: 1551
If you have a bean that engages in a transaction. You can more easily port it from system to system than a sequence based on a jdbc routine.
JDBC does not support a transaction involving a JMS data source.
You could wrap a legacy system with a bean managed transaction that jdbc would not be able to deal with.
tom walters
Ranch Hand

Joined: Feb 14, 2002
Posts: 34
ejb transaction can span more than just databases, while jdbc is limited to db transactions. how about when all we are dealing with is databases?
Rufus BugleWeed
Ranch Hand

Joined: Feb 22, 2002
Posts: 1551
It depends on the database and the JDBC drivers available. You mention Oracle to DB2 above, that should work just fine.
Database to database transactions are called something like distributed transactions or two phase commits.
Some influential entities in the consulting world think an EJB solution is often overkill. Security is the other great attribute of EJB systems according to Monson-Haefel.
HTH
Lipman Li
Ranch Hand

Joined: May 02, 2002
Posts: 122
It seems like impossible to relate two sort of Database in one trasaction by using JDBC only, at least you have to use the JTA explicitly in your code to support the two phase commit transaction. But if you're going to use EJB, they are handled by container.
Lipman
SCJP2
SCJD2
SCEA
[ August 25, 2002: Message edited by: Lipman Li ]
Yogesh Deshpande
Greenhorn

Joined: May 15, 2002
Posts: 19
Originally posted by tom walters:
a guideline is to use ejb if you are using transactions but i could do transactions without ejb by just using jdbc. what is the difference?
I suppose developers are not required to take care about the transactions management,access control or mulithreading,concurrenncy etc.
So as said earlier it depends on the requirement of the particular application.
But one thing is sure that we should avoid overkilling of technologies like EJB.
are they the same when i connect to just one transaction aware system (such as an oracle database)?
Replied above.
does the difference come into play when i want a transaction to span multiple transaction aware systems like oracle and db2?

EJB internally uses JTA to manage the transactions.So if u want to do it ur self the as suggested earlier u need to explicitely code JTA which could be again application specific.
-Yogesh
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: transaction in ejb vs jdbc
 
Similar Threads
Connecting to multiple databases using different jdbc drivers
Transactions
Questions
How to read my own uncommitted data but not others'
Distributed Transaction