views:

148

answers:

1

The PL/SQl cursor was getting hanged due to some reason, this makes my app to hang when try to loop through the ResultSet.Is there a way to handle this, like timing out the resultset if the database hangs?

+1  A: 

There is a setQueryTimeout(int) on the java.sql.Statement interface. You should call it before invoking the executeQuery().

You can also asynchronously cancel a running query by calling cancel() on the Statement too.

Edit: Oracle jdbc driver version 6 supports these methods for sure, as I'm using it in one of my projects.

kd304
But check that your JDBC driver really supports this feature as it is optional for ResultSets
Gábor Hargitai