471,887 Members | 803 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,887 software developers and data experts.

JDBC: How to determine an invalid connection

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
0 1207

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Nils Valentin | last post: by
3 posts views Thread by deegs_ca | last post: by
5 posts views Thread by oll3i | last post: by
2 posts views Thread by anokun7 | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.