Tuning Data Source Connection Pools 10-9
10.3 Enabling Connection Creation Retries
WebLogic JDBC data sources include the Connection Creation Retry Frequency option ConnectionCreationRetryFrequencySeconds in the
JDBCConnectionPoolParamsBean that you can use to specify the number of
seconds between attempts to establish connections to the database. If set and if the database is unavailable when the data source is created, WebLogic Server attempts to
create connections in the pool again after the number of seconds you specify, and will continue to attempt to create the connections until it succeeds. This option applies to
connections created when the data source is created at server startup or when the data source is deployed or if the initial capacity is increased. It does not apply to
connections created for pool expansion or to replace a defunct connection in the pool.
By default, Connection Creation Retry Frequency is 0 seconds. When the value is set to 0, connection creation retries is disabled and data source creation fails if the database is
unavailable.
See the JDBC Data Source: Configuration: Connection Pool page in the Administration Console or see JDBCConnectionPoolParamsBean in the Oracle WebLogic Server MBean
Reference for more details about this option.
10.4 Enabling Connection Requests to Wait for a Connection
JDBC data sources have two attributes that you can set to enable connection requests to wait for a connection from a data source: Connection Reserve Timeout
ConnectionReserveTimeoutSeconds and Maximum Waiting for Connection HighestNumWaiters. You use these two attributes together to enable connection
requests to wait for a connection without disabling your system by blocking too many threads.
See the JDBC Data Source: Configuration: Connection Pool page in the Administration Console or see JDBCConnectionPoolParamsBean in the Oracle WebLogic Server MBean
Reference for more details about these options.
Also see Enable connection requests to wait for a connection in the Administration Console Online Help.
10.4.1 Connection Reserve Timeout
When an application requests a connection from a data source, if all connections in the data source are in use and if the data source has expanded to its maximum capacity,
the application will get a Connection Unavailable SQL Exception. To avoid this, you can configure the Connection Reserve Timeout value in seconds so that connection
requests will wait for a connection to become available. After the Connection Reserve Timeout has expired, if no connection becomes available, the request will fail and the
application will get a PoolLimitSQLException exception. PostgreSQL
SQL SELECT 1 Progress
SQL SELECT COUNT FROM SYSTABLES Sybase
SQL SELECT 1
Table 10–1 Cont. Default Test Table Name by DBMS
DBMS Default Test Table Name Query
10-10 Oracle Fusion Middleware Configuring and Managing JDBC Data Sources for Oracle WebLogic Server
If you set Connection Reserve Timeout to -1, a connection request will timeout immediately if there is no connection available. If you set Connection Reserve Timeout
to 0, a connection request will wait indefinitely. The default value is 10 seconds.
See Enable connection requests to wait for a connection in the Oracle WebLogic Server Administration Console Help.
10.4.2 Limiting the Number of Waiting Connection Requests
Connection requests that wait for a connection block a thread. If too many connection requests concurrently wait for a connection and block threads, your system
performance can degrade. To avoid this, you can set the Maximum Waiting for Connection HighestNumWaiters attribute, which limits the number connection
requests that can concurrently wait for a connection.
If you set Maximum Waiting for Connection HighestNumWaiters to MAX-INT the default, there is effectively no bound on how many connection requests can wait for a
connection. If you set Maximum Waiting for Connection to 0, connection requests cannot wait for a connection. If the maximum number of requests has been met, a
SQLException
is thrown when an application requests a connection.
10.5 Automatically Recovering Leaked Connections
A leaked connection is a connection that was not properly returned to the connection pool in the data source. To automatically recover leaked connections, you can specify a
value for Inactive Connection Timeout on the JDBC Data Source: Configuration: Connection Pool page in the Administration Console. When you set a
value for Inactive Connection Timeout, WebLogic Server forcibly returns a connection to the data source when there is no activity on a reserved connection for
the number of seconds that you specify. When set to 0 the default value, this feature is turned off.
See the JDBC Data Source: Configuration: Connection Pool page in the Administration Console or see JDBCConnectionPoolParamsBean in the Oracle WebLogic Server MBean
Reference for more details about this option.
Note that the actual timeout could exceed the configured value for Inactive Connection Timeout. The internal data source maintenance thread runs every 5
seconds. When it reaches the Inactive Connection Timeout for example 30 seconds, it checks for inactive connections. To avoid timing out a connection that was reserved
just before the current check or just after the previous check, the server gives an inactive connection a second chance. On the next check, if the connection is still
inactive, the server times it out and forcibly returns it to the data source. On average, there could be a delay of 50 more than the configured value.
10.6 Avoiding Server Lockup with the Correct Number of Connections