469,271 Members | 1,009 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

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 1137

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
oll3i
5 posts views Thread by oll3i | last post: by
2 posts views Thread by anokun7 | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.