By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,334 Members | 1,266 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,334 IT Pros & Developers. It's quick & easy.

JDBC: How to determine an invalid connection

P: n/a
Hello everybody,

we have the following problem with our Java application: Within our app we
have connection pool for JDBC connections which always should be opened.
We need this since several users should be served at the same time. The
app is running on a pc and is always available. But the problem is that
the data base (DB2-UDB) is on a AS400 which is rebooted every night. That
means that the JDBC connections become invalid. But unfortunately I do not
find the right approach so the app 'knows' what has happend and react with
a reconnect (and i do not understand why there is no callback method or
rather a addConnectionListener method. It could be so simple...).

So the question is how to detect that the connection is invalid. Is there
a reliable SQLException error code which I could use when I try to execute
a sql statement? Not to forget that the app uses transactions what means
that I may not catch any exception. Can anyone give me me a hint or
explain how to deal with the problem?

Thanks in advance
Robert Schneider
PS: Is it a problem to keep DB connections open, never close it?


Nov 12 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.