commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joao Batistella <joao-p-batiste...@ptinovacao.pt>
Subject RE: Connection is closed
Date Tue, 30 Mar 2004 08:41:00 GMT
I've already set the validationQuery to test the connection. 
This (the connection is closed error) doesn't happen so often, only
sometimes. But it's strange because there is no pattern.
The most strange thing is that I haven't had this error while not using
DBCP... I was using a direct JDBC connection, without a connection pool.
This is because I was asking if DBCP could close the connection after some
time.

Thanks for your help.
JP

-----Original Message-----
From: Craig McClanahan [mailto:craigmcc@apache.org]
Sent: segunda-feira, 29 de março de 2004 21:14
To: Jakarta Commons Users List
Subject: Re: Connection is closed


Joao Batistella wrote:

>Thanks.
>I do that. I only deal with the connection returned by DBCP. Is there a
>  
>
>timeout attribute (or anyother thing) that can close the connection?
>
>  
>
A "connection closed" error can be caused by the database end.  For 
example, if your database is configured for connections to time out, the 
database will do so without DBCP even knowing about it -- and I'm fairly 
certain that Oracle supports such a configuration option.

A conventional approach to dealing with this is to set the 
"validationQuery" property to some SQL statement that will be used to 
validate whether a connection is alive before it's returned to you from 
getConnection() -- something like "SELECT 1 FROM DUAL" works fine for 
Oradle.  The pool will then detect that the "real" connection can't be 
used any more, close it, and then go grab a new one, without your 
application having to worry about this situation.

Craig


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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message