This topic describes the configuration parameters for a connection pool, including ZDAL parameters, Druid parameters, DBCP parameters, C3P0 parameters, and JDBC parameters.
Data source configuration parameters
Parameter description |
Description |
ZDAL parameters |
Druid parameters |
DBCP 2 parameters |
C3P0 parameters |
|---|---|---|---|---|---|
| Initial Connections | The number of connections established during connection pool initialization. | prefill=true initialized to minConn | initialSize |
initialSize |
initialPoolSize(3) |
| Minimum Connections | The minimum number of connections that the pool maintains. | minConn(0) | minIdle |
minIdle |
minPoolSize(3) |
| Maximum Connections | Maximum number of connections that the pool can allocate to applications at once. | maxConn(10) | maxActive |
maxTotal |
maxPoolSize(15) |
| Idle Connection Timeout Period | Evict connections that have been idle for too long. Set the pool timeout to account for the network idle timeout so that applications do not reuse stale connections. | idleTimeoutMinutes(30min) | minEvictableIdleTimeMillis |
minEvictableIdleTimeMillis |
maxIdleTime (0 indicates no timeout) |
| Timeout period for obtaining a connection from the connection pool | If set too high, a full connection pool can cause the application to respond too slowly. | blockingTimeoutMillis(500ms) | maxWait |
maxWaitMillis |
checkoutTimeout (0 indicates no timeout) |
| Timeout period for unreleased connection acquisition | If the timeout period expires and the connection has not been returned to the connection pool, it will be directly destroyed. This helps prevent connection leaks but affects the time limit for transaction usage. | None | removeAbandonedTimeout |
removeAbandonedTimeout |
None |
For Druid and DBCP 2 settings, see the Druid example and the DBCP example.
JDBC configuration parameters
The following JDBC parameters are important and must be set. They can be configured in the ConnectionProperties of the connection pool or in the JDBC URL. The specific parameters and their descriptions are listed in the following table.
Parameter |
Description |
|---|---|
| socketTimeout | Defines the network socket timeout (SO_TIMEOUT), in milliseconds. When the value is 0, this timeout is disabled. Default value: 0 (standard configuration). |
| connectTimeout | Connection timeout value, in milliseconds. A value of 0 indicates no timeout limit. Default value: 30000. |
Suggestions on connection pool settings
For a management console application, a minimum pool size of two connections is generally sufficient. Adjust it for the concurrency and transaction duration of your workload.
Set the idle connection timeout. A value of 30 minutes is recommended.
By default, MySQL actively disconnects idle connections after 8 hours, which the client cannot detect, leading to stale connections. The connection pool can validate whether a connection is alive through mechanisms such as heartbeats or testOnBorrow. Connections that exceed this idle time are directly disconnected.