This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes connection pooling using directcoonection problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "connection pooling using directcoonection problem" Watch "connection pooling using directcoonection problem" New topic
Author

connection pooling using directcoonection problem

swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

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.
 
Consider Paul's rocket mass heater.
 
subject: connection pooling using directcoonection problem
 
Similar Threads
JDBC 3.0 api Connection pooling
socket write error
Connection Pooling
why should i use connection pooling ?
Connection Pooling in WebSphere App Server