My Oracle Support Banner

How to use the JDBC setQueryTimeout Call to Cancel a Long Running Query and raise an ORA-1013 (Doc ID 412171.1)

Last updated on MARCH 29, 2018

Applies to:

JDBC - Version 10.2.0.3 to 12.2.0.0.0 [Release 10.2 to 12c]
Information in this document applies to any platform.

Goal

This article provides a very simple JDBC standalone program to demonstrate the use of the JDBC standard method setQueryTimeout() which is available for all JDBC java.sql.Statement objects.  The article will also discuss limitations that may prevent the setQueryTimeout() from working properly due to limitations of both the database and the JDBC driver.

The Statement.setQueryTimeout(int seconds) relies on the Statement.cancel() method and basically implements a thread to cancel a long running query after a specified delay.

This demonstration builds on  <Note 357615.1> How to simulate a slow query. Useful for testing of timeout issues

 This program has been tested using RDBMS 10.2.0.3 ( Linux x86 32-bit) JDBC/thin 10.2.0.3, JDBC/thin 11.1.0.6, JDBC/thin 11.2.0.2 and JDK 1.5 / 1.6 ( Windows client), and JDBC 12c.

Solution

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.