Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

transaction in ejb vs jdbc

 
tom walters
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic