Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Passing a DataSource from JNDI to my DAO through Session Bean  RSS feed

 
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys

I'm getting a DataSource through JNDI and passing that to my DAO to get a connection. This all happens inside a Stateless session bean. I was wondering, if some sort of error occurs during my database process(when I use my DAO), is transaction supported during this phase? I mean, would my transaction rollback?




Thanks!
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Timothy Sam:
if some sort of error occurs during my database process(when I use my DAO), is transaction supported during this phase?



Which transaction mechanism you are using? Anyway, you can do the dollowing:

1) Use CMT for the session bean method,
2) Put your bean method code in a try catch,
3) Throw exception from teh dao methods explicitly in case of issues / exception received,
4) In bean methods catch you can call setRollBackOnly on context object.

Hope this solves your problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!