commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dirk Verbeeck <dirk.verbe...@pandora.be>
Subject Re: [DBCP] Question regarding BasicDataSource
Date Sat, 19 Feb 2005 10:11:54 GMT
Hi Sanjeet,

You are absolutely correct, conn.close() should return the connection 
back to the pool and a finally block is the best place to do it.
The default behaviour of waiting when you go over the MaxActive, is 
probably what you see.

Can you post a small piece of code showing the problem? It is often a 
small oversight. Often it is a variable scope issue, local/class 
variable declaration.

Cheers
Dirk

Sanjeet Joshi wrote:
> Hi,
> 
> I am developing a webapp using Struts, Tomcat, JSP, Servlets and MySQL.
> 
> I am using BasicDataSource for JDBC connection pooling needs. I have a
> question regarding returning the connections back to the pool.
> 
> Whenever I get a connection using
> 
> Connection conn = ds.getConnection();
> 
> I make sure that in the finally{} or any other appropriate place I
> close the connection using
> 
> if(conn!=null) conn.close();
> 
> I am wondering if conn.close() is indeed returing the Connection back
> to pool or not. Does it? When I checked the source code it seems it
> does. But after getting and closing the connections 8 times the nineth
> getConnection() call just goes in an endless loop.
> 
>>>From the docs and sources I can see that if I hit the MaxActive()
> count the next call to getConnection() will wait till an object is
> returned to the pool. But in my case I make sure that I return the
> objects back to the pool each time I get them. So why is it going in
> wait() ?
> 
> Please tell me what could be going wrong?
> 
> Regards
> Sanjeet


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message