• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question on Best Practice for Database Connections  RSS feed

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

What is the best practice when utilizing a WebSphere connection pool? Currently, a application that I am working on, opens a connection when needed and passes the object to the Data Access Object which then closes the connection when it is finished with it. Would it be better to open ONE connection and store it in a session, that way all DAOs can access it whenever needed?

Thanks,
Lulu
 
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In general, get a connection only when you need it, then return it to the pool as soon as you are finished with it.
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would not store the connection in a session. Depending on your site you probably do not want a connection hanging open that long
 
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to JDBC...
 
Ranch Hand
Posts: 1084
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest don't put connection in session. Create a datasource in websphere make connection from datasource when you need and close it as soon as you are done.

rest leave on websphere.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!