This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

connection pooling using directcoonection problem

 
swapnil paranjape
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i am working on code which makes direct connection with database using driver manager class and stores this connections in arraylist as connection object and thus make a pool of connection which is used in program

now ,once the connection is used ,it should be realsed and make available for further release.

so what check needs to be done to ensure that connection is released.

also coonection pooling code works fine on weblogic but doesnt run on websphere ,what can be the possible cause?

is the approach for connection pooling right? and what can be reason for code,not to run on websphere
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swapnil,
A more traditional approach would be to use a connection pooling driver. That way the application server can handle the connections for you.

The next best thing is to use a connection pooling library like the one in Apache Commons.

If you really have to write your own, check that all of the code is releasing connections. Also, check you clean out the pool every so often of stale connections.
 
swapnil paranjape
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
thanx for the help..but existing code i am working on uses this kind of connection pooling where pool of direct connection is stored in the arraylist

this code works fine in tomcat but gives not enough connection in websphere

actually when there are not enough connection then i am running a thread which will create more direct connection ...which will in a way help for getting connections.


as you have mentioned clean the pool for stale connection...how should i do that
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One approach is to have a thread that goes through the pool every so often to see if the connections are closed. This won't get all of the stale connections, but it will get some.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic