• Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing a DataSource from JNDI to my DAO through Session Bean

 
Timothy Sam
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!
 
Anirban Basu
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!