commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Carman <ja...@carmanconsulting.com>
Subject Re: expected behavior of the DBCP (when a db session is killed)
Date Wed, 24 Feb 2010 16:59:57 GMT
It will attempt to establish a new connection.

On Wed, Feb 24, 2010 at 11:56 AM,  <couva@sapo.pt> wrote:
>
> what happens if validateQuery() determines that the connection is invalid?
> Will return another valid connection (in runtime) or will return an
> exception which must be handled?
>
> Thanks!
>
> Citando cyrille.roy@free.fr:
>
>> Hi,
>>
>> you will get a connection object that is no more linked to your db, so
>> your thread might get stuck when trying to get data.
>>
>> To prevent this you can:
>> - set testOnBorrow = true
>> - set the validation query
>>
>> This will validate the connection before taking it out of the pool, so you
>> make sure the connection is valid once taken out of the pool.
>> This will cause dbcp to make an extra sql call to your db for every
>> "business" sql, so be sure your db can cope with this extra load.
>>
>> Note that you are not guaranted that the connection is alive when you want
>> to use it then, i.e network could break after you picked the connection.
>> To handle this case, you can use the Statement.setTimeout(), but I did not
>> test that yet.
>>
>> Hope this helps,
>> Cyrille
>>
>> ----- Mail Original -----
>> De: "James Carman" <james@carmanconsulting.com>
>> À: "Commons Users List" <user@commons.apache.org>
>> Envoyé: Mercredi 24 Février 2010 14h14:59 GMT +01:00 Amsterdam / Berlin /
>> Berne / Rome / Stockholm / Vienne
>> Objet: Re: expected behavior of the DBCP (when a db session is killed)
>>
>> Do you have the validation query set?
>>
>> On Wed, Feb 24, 2010 at 7:12 AM,  <couva@sapo.pt> wrote:
>>>
>>> Good morning,
>>>
>>> What is the expected behavior of the DBCP when I try to get a connection
>>> from the pool and the connection is invalid (eg a session kill was made
>>> in
>>> the database)?
>>>
>>> Is it identified that the conn is invalid, the conn is refreshed and
>>> returned a valid connection or is returned an exception?
>>>
>>>
>>> Context initContext = new InitialContext();
>>> Context envContext  = (Context)initContext.lookup("java:/comp/env");
>>> DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");
>>>
>>>
>>> ######### A session KILL is made in the database ###########
>>>
>>> Connection conn = ds.getConnection();
>>>
>>> ######### what's happen here? ##############
>>>
>>> Thanks,
>>> Best Regards
>>>
>>> Thanks
>>> Best Regards
>>>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: user-help@commons.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

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


Mime
View raw message