• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Handling Transaction in Stateless session bean

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd ask this question on the javaranch bea weblogic question forum. They'll be able to handle it better.
 
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic