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]
