Hi Everybody, Iam trying to execute a statless session bean. I have a method XXX, in which i use two SQL for insert of records, in two different tables. Now, what i want is, if the first SQL execeutes sucessfully and the second raises exception, then both there should be a rollback on both of the SQL statements. I have tried using Required in the Deployment Descriptor, But that doesn't work. I want the container to handle this situation. Iam using weblogic 6.1 eval copy. Thanks in Advance. Amit
Hi Amit, According to EJB specification. If you can have two scenarios 1) Container Managed TRANSACTION 2) Bean Managed TRANSACTION (Not Persistance) If Container Manged transaction: Folow these steps: a) You execute the first SQL statement. b) You execute the second SQL statement. c) Catch the SQLException and invoke 'setRollBackOnly()' method. This should solve your problem. If Bean Managed Transaction: Follow these steps: a)Get user transaction and start the transaction using 'trans.begin()' a) You execute the first SQL statement. b) You execute the second SQL statement. c) Catch the SQLException and invoke 'trans.rollback()' method. This should solve your problem. Hope this helps. thanks, Ramdhan YK
Ram Dhan Yadav (SCJP, SCWCD, SCJA-I, IBM EC(483))
"We are what we repeatedly do. Excellence, then, is not an act, but a habit."