Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

When to open / close Datasource connection in EJBs

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

I'm pretty new to the whole EJB scene, so please excuse my ignorance.
I'm thinking of using the Session Facade pattern for our EJB application, with bean-managed EJBs. The entity beans will look up container-configured datasource (oracle8 db) with JNDI and use that for persistence. The question I have is, at what point should the datasource connection be created and closed? As I understand, the container (jboss 4.0.0) will pool existing connections and lend them to the entity beans upon lookup. Does this mean the entity beans shouldn't close the connection on their own?

Thank you in advance,
Yuriy
 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In BMP beans, you should open and close database connections in each of create(),load(),store(),findBy..(). closing a connection just return the connection to connection pool, it won't actually close the connection with database. Its handled internally by ConnectionManager.
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great, thanks!
 
You got style baby! More than this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic