Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session bean in database transaction

 
shekarasankaran
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
Would it be advisable to use session bean inspite of entity bean to perform any database transaction . If yes then tell y or else if not advisable tell what advantages do we gain from an entity bean
Thanks in anticipation
 
Rasmeet Devji
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stateless Session Beans could be used for transactions involving more than one table. This is where your Java Transaction API and TX DataSource come into picture.
You could get the Transaction object from the EJBContext's getUserTransaction() method
and then, get your SQL statements in place within a try and catch block.
Remember, you need to use the transaction.begin(), transaction.commit() and transaction.rollback() methods to ensure your transaction works fine !!!
Hope this helps.
Regards.
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"shekarasankaran",
Thanks for joining JavaRanch, but could you just take a quick look at the naming policy and edit your profile accordingly.
Thanks!
Simon
Bartender (moderator) of "J2EE and EJB" forum
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic