简体   繁体   中英

How to Timing out java.sql.ResultSet

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM