Ryunix wrote:
Hi Carman,
I had already set the validation query and enable the removeAbandoned to
true
Do you have testOnBorrow set to true? That is the property that determines whether or not connections are validated on checkout.
It seems that on some occasion when the removeAbandoned closes the
connection, it will close the underlying poolable connection, and when my
application uses the connection, i can see that the connection object
returned by session.getConnection() would have the value isClosed=false, but
when I expand the connection object to the poolable connection, i can see
that isClosed=true.
If your application/Hibernate is properly closing connections, you do not need to set removeAbandoned = true. If you do use this, you need to make sure that the removeAbandonedTimeout is longer than the maximum amount of time that your application will hold onto a connection that has been checked out from the pool without using it.
Phil



jwcarman wrote:
You can turn on the connection validation [1] by supplying a
validation query.  Then, DBCP can test if the connection is okay when
it tries to let you borrow it.

[1] http://commons.apache.org/dbcp/configuration.html


On Fri, Apr 17, 2009 at 2:07 PM, Ryunix <[email protected]> wrote:
Dear All,
we have an application which using hibernate with DBCP.
and the application will access the database using hibernate session
which
obtain the connection from the dbcp pool. The application will provide
webservices to be used by other application.

In some cases where the 'poolable connection' obtained by the hibernate
session is closed, our application will throw error saying the connection
is
closed to the webservice client, and this error will only occur at that
particular web service call. At the next call, the webservice can return
result to the caller successfully.

To prevent the error, we had added an intermediate 'loop' function to
test
the connection obtained by the session, if the connection (poolable
connection) is closed, we will issue conn.close() and release the session
.
However, it seems that the connection obtained through
session.getConnection() at every loop is always the same, and hence would
have the same 'connection is closed' issue.

May I know if there is any way for me to force the session.getConnection
to
return me a new 'valid' connection?

Thanks guys in advance

--
View this message in context:
http://www.nabble.com/Using-DBCP-with-Hibernate---How-to-reconnect-if-the-poolable-connection-is-closed-tp23102913p23102913.html
Sent from the Commons - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]






---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to