You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Mohammad Irfan <ir...@gmail.com> on 2004/12/06 07:01:42 UTC

DB Connection TimeOut

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


Re: DB Connection TimeOut

Posted by haipeng du <ha...@gmail.com>.
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 <ir...@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