Set a network timeout to avoid possible long or indefinite waiting for a response from the database in the event of a network or database failure.
The query timeout limits execution time of a query; the network timeout controls the underlying communication channel between the JDBC driver and the database.
Full support for timeouts requires the network timeout to be configured on the JDBC driver. This feature is JDBC driver dependent.
For example, when a query timeout is detected and the JDBC driver sends a notification to the database, a communication timeout may occur. This will not be detected (or the detection can take arbitrary time) unless the network timeout is explicitly configured.
Not configuring the network timeout causes either:
|
Below are details for configuring the network timeout for some common database drivers.
Database, JDBC driver | Where to configure | Property name | Unit | Example |
---|---|---|---|---|
Oracle, Thin driver, v10.1.0.5+ |
|
|
ms |
|
Oracle, Thin driver, older |
|
|
ms |
|
Oracle, OCI driver |
Not supported. |
|||
MySQL, v3.0.1+ |
|
|
ms |
|
PostgreSQL, v8.4+ |
|
|
s |
|
Always check the vendor’s documentation for the right property name, place of configuration, and any other restrictions or guidelines. |
As a general guideline: the value for network timeout should be greater than maximum time of a query or transaction.
The resource adaptor internally sets the query timeout for the JDBC driver (more precisely, for each issued query
statement) equal to 1.5 times DbQueryDataSourceProfile
QueryTimeout
. The network timeout should not be less than 1.5
times the QueryTimeout
, as otherwise the JDBC driver may end a query prematurely with a failure.