commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: [Pool] Newbie question on pools (modified subject)
Date Wed, 19 Mar 2003 16:22:39 GMT


On Wed, 19 Mar 2003, Donie Kelly wrote:

> Date: Wed, 19 Mar 2003 11:07:46 -0000
> From: Donie Kelly <donie.kelly@tecnomen.ie>
> Reply-To: Jakarta Commons Users List <commons-user@jakarta.apache.org>
> To: 'Jakarta Commons Users List' <commons-user@jakarta.apache.org>
> Subject: [Pool] Newbie question on pools (modified subject)
>
> Hi
> Sorry about posting without proper subject. I'm resending in case a lot of
> you are using filtering.
>
> Donie
>
> -----Original Message-----
> From: Donie Kelly [mailto:donie.kelly@tecnomen.ie]
> Sent: 19 March 2003 11:03
> To: Jakarta Commons (E-mail)
> Subject: Newbie question on pools
>
> Hi all
>
> I've looked through the source and all the javadocs and I cannot find a way
> to do the following with the pool library. Note I have marked that I can
> achieve parts of the intended functions:
>
> 1)      Get a connection from the pool (I can do this)
> 2)      Use the connection (I can do this)
> 3)      Return the connection to the pool (I can do this)
> 4)      When I get a connection and I have detected it has failed how can I
> mark it for removal as it may have been dropped by the server at the other
> end of the connection (HOW TO??)
>
>

If you are using the [pool] APIs directly, you can set the testOnBorrow
and/or testOnReturn properties to validate objects as they are being
borrowed, or as they are being returned.  See the [pool] API docs on
GenericObjectPool for more info.

If you are using something like BasicDataSource from [dbcp] for database
connection pools, these APIs let you define a 'validationQuery' parameter
that represents an SQL SELECT statement.  The pool will ensure that this
statement executes with no failures before letting you borrow it, throwing
the connection away if not.  There are other tweaks for things like
periodically testing the idle connections in the pool as well.

> I understand that I can use the pool ObjectPoolFactory to test connections
> on retrieval and submission to the pool but this is an overhead I don't
> want. I want the pool to drop the connection when the application has
> decided it is bad. I know the other way is desirable and I will probably
> implement this by using the evictor thread but surely it's important for the
> application to be able to decide that the connection is useless??
>

If you don't want the overhead of testOnBorrow (it's a price I feel
willing to pay, because the app should not even have to worry about things
like this), then you probably want to explore the testOnReturn thing
instead.

> The connection I'm pooling is a Corba connection object.
> Thanks for any insights or help.
>
> Donie
>
>

Craig


Mime
View raw message