Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to detect stale connections?

843859Nov 9 2006 — edited Nov 13 2006
'm working on an application that monitors tables on an AS/400 and transfers them in real time to a MySQL database. The application needs to be up 24X7. Once a week the AS400 is taken off line for about 15 minutes. When the AS/400 goes down I expect SQLExceptions to be thrown but instead my code seems to hang and no exceptions are thrown. My intention is to monitor for exceptions and eventually reconnect to the AS/400 when it is back up.

In the code sample below the connection is stale before the method is entered, but no exceptions are thrown and execution stops when at "resultSet = stmnt.executeQuery(sql);"

Any insights will be appreciated.

Relevant Code

public void setUpdatableResultSet(String sql) throws SQLException {
stmnt = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
resultSet = stmnt.executeQuery(sql);
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 11 2006
Added on Nov 9 2006
8 comments
841 views