commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From haipeng du <haipen...@gmail.com>
Subject Re: DB Connection TimeOut
Date Mon, 06 Dec 2004 06:27:01 GMT
I think you got a same problem as me. Here is the method somebody told me.
One simple approach is to set the "validationQuery" property to an SQL
statement that does a simple select or something.  If this is set,
DBCP will ensure that this query works successfully before handing you
back the connection.  If the database has timed out the connection
while it was sitting in the pool, the query will fail, and DBCP will
close this connection and go grab another one (creating a new one if
needed). To make sure you set TestOnBorrow to be true at least.
 Good luck.
Haipeng



On Mon, 6 Dec 2004 13:01:42 +0700, Mohammad Irfan <irfan199@gmail.com> wrote:
> Hello, my name is Irfan. I have a problem about dbcp connection. After
> I acquire a data source when I use the getConnection method for a DB
> server that down, it stalled for a long time. Especially in Linux
> platform. I figured that the connection timeout depends on the system.
> It use default system connection timeout.
> The Question is, how to set the connection timeout so in every
> platform I have the same connection timeout time. I've tried the
> setLoginTimeout method for the datasource but it's useless. Infact, it
> throws Unsuported Operation exception.
> Thank you for the answer.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


-- 
Haipeng Du
Software Engineer
Comphealth, 
Salt Lake City

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


Mime
View raw message