You can configure a timeout for connection validation by
the Java™ Database Connectivity (JDBC) driver through
a data source custom property in the data source configuration panels.
About this task
You can choose between validating connections with the JDBC
driver or by having the application server run a SQL query. Select
one or both of the following connection pretest attributes:
- Validate new connections
- Validate existing pooled connections
By default, connection validation is disabled. When you save
the configuration for the data source, the administrative console
supplies only the option that is selected. The administrative console
will select validation by timeout or validation by a query, but if
validation is not enabled then the application server will select
neither option.
Procedure
- Open the administrative console.
- Go to the panel for
the data source.
- Select
- Select .
- Go to the Connection Validation Properties section.
- Select the type of connections that the application server will validate.
Avoid trouble: You must make a selection here. If you do not select
one or both of these options, you cannot select Validation by JDBC Driver in
the following step. The Validation by JDBC Driver timeout feature is only
available for JDBC providers that comply with the JDBC 4.0 specification.
- Select Validate new connections. This option specifies that the
connection manager tests newly created connections to the database.
- Select Validate existing pooled connections. This option specifies
that the connection manager tests the validity of pooled connections before returning them to
applications.
- You can also select both options.
- Click Validation by JDBC Driver.
If the JDBC driver does not implement the JDBC 4.0 specification, or if the
Connection.isValid method raises an error, the application server issues a warning when
Validation by JDBC driver is configured. Alternatively,
Validation
by JDBC Driver does not display on the console panel. A JDBC provider might claim
compliance for the JDBC 4.0 specification, but not implement the
Validation by JDBC
driver timeout feature.
Deprecated feature: Connection
validation by SQL query is deprecated. Use validation by JDBC Driver instead.
- Enter the timeout value in the input box.
The
timeout value is in seconds.
Avoid trouble: If retries are
configured, meaning the retry interval is not set to 0, for Validate
new connections or Validate existing pooled
connections, then the full value of the timeout applies
to each retry. For each retry, the application server waits for the
retry interval. Then the JDBC driver uses the full value of the timeout
to validate the connection
- Save the data source configuration.
What to do next
If you are modifying an existing data source, restart your
server for this change to go into effect. If this is a new data source,
restarting the server is not necessary.