• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Connection object from EJB or DAO

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm using stateless session EJB which uses DAO class for data manipulating.
The question is should I get DB Connection object from EJB and give it for DAO class to be used or is it better idea that DAO class would open Connection object itself and use it for data manipulating in database?

Or does it matter which one is getting the Connection object?

I read somewhere that EJB's passivate and activate method should close nad repeopen Connection when those methods are called.

So, which one is better place to open Connection from Datasource EJB or DAO?

Cheers!
 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would do it in the DAO. Why have the EJB do it if the EJB isn't making an Database calls?

You shouldn't be holding onto a connection so why would you need to close it and reopen it?
 
Jimmy B Deacon
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I read somewhere SessionBean's passivate and activate method can close
connection and then reopen it.

That made me think that is that a feature that should be enabled.
DAO class knows nothing if EJB is thrown to disk (passivate) and reread (avtivate).

But that's I asked because I don't if this is issue taht should be
concerned.

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