Defines the maximum number of seconds during which a query should execute for the current SQL Server connection.
Syntax
SET PRO_SERVER QUERY_TIMEOUT n ;
Parameters
n
Indicates the maximum number of seconds during which a query should execute before it is automatically cancelled by the SQL server. Setting an n value of 0 disables a previously set query timeout.
Notes
Execution of this command is restricted to DBAs. Any value set with this command is in effect for the duration that the database is up and running.
Should a query timeout value be set for an individual connection via the command SET PRO_CONNECT QUERY_TIMEOUT the lower of the timeout values for the connection and the server takes precedence.
This example sets the query timeout to 30 seconds:
Statement stmt = connection.createStatement();
String MySetQueryTimeout;
String MyClearQueryTimeout;
MySetTimeout = "SET PRO_SERVER QUERY_TIMEOUT 30";
MyClearTimeout = "SET PRO_SERVER QUERY_TIMEOUT 0";
// Set SQL Server timeout for query execute and fetch
stmt.executeUpdate( MySetQueryTimeout );
// Add code here to perform queries
// Clear SQL Server timeout for query execute and fetch
stmt.executeUpdate( MyClearQueryTimeout );