-
Notifications
You must be signed in to change notification settings - Fork 438
Timeouts used by the JDBC driver
Jeffery Wasty edited this page Apr 18, 2023
·
3 revisions
As of driver version 12.2.0, there are five timeouts used by the JDBC driver. This same information can be found in the list of connection properties for the driver.
For the initial connection, loginTimeout
is used:
-
loginTimeout
is the amount of time, in seconds, the driver waits to establish a connection to the server. If this amount is exceeded, an error is returned, and no open connection is formed. A zero value indicates that the timeout is the default system timeout, which is specified as 15 seconds. Any non-zero value is the number of seconds the driver should wait before timing out a failed connection. If you are having trouble establishing a connection with the JDBC driver, a good first step is to increase this timeout to 90, or even 120 seconds.
Once the connection has been established, queryTimeout
, cancelQueryTimeout
, and lockTimeout
are used during statement executions. socketTimeout
is used for any driver communication with the server.
-
queryTimeout
is the time, in seconds, the driver will wait, after sending an execute command to the server, to receive a reply from the server with data. If this time is exceeded, the command is cancelled. Exceeding this timeout will not close the connection. The default value is -1, which means infinite timeout. For more information on queryTimeout, see its corresponding wiki page. -
cancelQueryTimeout
is the time, in seconds, the driver will wait for an acknowledgement of the QueryTimeout cancellation from the server, before forcefully terminating/closing the connection. That is, the driver waits the total amount ofcancelQueryTimeout
+queryTimeout
seconds, before dropping the connection and closing the channel. The default value for this property is -1 which is an infinite wait time. -
lockTimeout
is the amount of time to wait for a lock to be freed, in cases where there is a lock blocking statement execution. This does not result in a closed connection. The default value for this property is -1 and behavior is to wait indefinitely. -
socketTimeout
applies to socket communications with the server. If at some point, the server stops communication with the driver (i.e. not acknowledging or replying to data), the driver waits for a length equal to the socketTimeout before closing the connection. The default value is 0, which means infinite timeout. For more information on socketTimeout, see its corresponding wiki page.
The information is also summarized in the below table:
Property | Summary | Default | Connection result |
---|---|---|---|
loginTimeout |
The number of seconds the driver should wait before timing out a failed connection. | 0 [15 seconds] | Closed connection |
queryTimeout |
The number of seconds to wait before a timeout has occurred on a query. | -1 [Infinite timeout] | Open connection |
cancelQueryTimeout |
The number of seconds to wait for an acknowledgement of the QueryTimeout cancellation. | -1 [Infinite timeout] | Closed connection |
lockTimeout |
The number of milliseconds to wait before the database reports a lock time-out. | -1 [Infinite timeout] | Open connection |
socketTimeout |
The number of milliseconds to wait before a timeout is occurred on a socket read or accept. | 0 [Infinite timeout] | Closed connection |