File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes session bean in  database transaction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "session bean in  database transaction" Watch "session bean in  database transaction" New topic

session bean in database transaction


Joined: Nov 12, 2001
Posts: 18
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

Joined: Dec 08, 2000
Posts: 17
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.
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
Thanks for joining JavaRanch, but could you just take a quick look at the naming policy and edit your profile accordingly.
Bartender (moderator) of "J2EE and EJB" forum
I agree. Here's the link:
subject: session bean in database transaction
It's not a secret anymore!