managing transactions in EJB
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   priya_dhanapalan
Posted On:   Sunday, March 13, 2005 11:36 PM


How to manage ejb transactions.. for example i am having one server method from that i am calling one more method how to manage transactions between this method if some exception occurs how to rollback...

Re: managing transactions in EJB

Posted By:   samuel_uchula  
Posted On:   Monday, March 21, 2005 05:08 AM

Hai priya,

In EJB you have to first tell us what container are u using for EJB. Like in websphere you have to specify whether the transaction type is container-managed or application-managed.
If for container-managed u have to set the attributes 1.requires 2.requires new 3. mandatory 4. not supported 5. supported depending on ur requirement. And also in the end of the method which u want to rollback if any problem arises should be enclosed with the try catch
ex:
try{
//place ur code or SQL Statements.

}
catch(Exception e)
{
return new EjbException(e.getMessage())
}

This EJBException informs the container that the method has failed and it will rollback the transaction.

If u want to manage the transactions all by the application itself u have the transaction API's and u have to begin a transaction and end a transaction.

Bye
Samuel
About | Sitemap | Contact