commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cindy Ballreich <ci...@ballreich.net>
Subject Re: [DBCP] Maintaining a minimum number of connections
Date Thu, 10 Apr 2003 23:33:24 GMT
At 11:07 AM 4/11/03 +1200, Jason Lea wrote:
>
>Are you checking the pool.getNumIdle() & pool.getNumActive() or are you 
>looking at MySql's list of open connections?
>
>If MySql shows no connections then it could be the wait_timeout setting 
>in MySql is closing the idle connections.  MySql's log might show this.
>
>If pool.getNumIdle() is 0, then this measures the number of objects in 
>the pool (the actual connection may or may not be open).  The Evictor 
>can check idle connections using the validation string to check if they 
>are still open/working.  But as you have turned this off it won't be 
>checking and throwing away objects.
>
> From what I can see, the functionality you want doesn't exist in DBCP. 
>  It would be nice if you could set the minimum number of connections 
>(active or idle) that should be open.  It would involve a couple of 
>checks when objects are returned and in the Evictor, so that if the 
>object is destroyed and the total number of connections is below the 
>minimum then  a new object should be created and added to the pool.
>
>You could compensate for this in your own application.  You could start 
>your own monitoring thread that counts the total number of connections 
>in the pool (pool.getNumIdle()+pool.getNumActive()).  If it is below 
>your threshold you could call pool.addObject() until you have enough.
>
>pool.addObject() comments says...
>
>     /**
>      * Create an object, and place it into the pool.
>      * addObject() is useful for "pre-loading" a pool with idle objects.
>      */
>
>The other problem is DBCP doesn't have commons-logging built in so it is 
>hard to see if your objects are being evicted or not.
>

Thanks for replying Jason,

Yes, I'm using getNumIdle() and getNumActive() to check on the connection count.

The rest of your response doesn't exactly fill me with hope. I've been thinking about adding
a monitoring thread, but that seems so kludgy. I guess that's what I'll have to do.

I agree that the lack of logging is a problem. Some kind of a listner would be nice as well.

Thanks again.

Cindy

Mime
View raw message