The minSize Constraint
The IllegalArgumentException occurs because c3p0 requires the minSize property to be an integer greater than or equal to 1. Setting this value to 0 or a negative number is not supported by the pool implementation and will trigger a runtime exception during the initialization of the ComboPooledDataSource.
Valid Range and Constraints
To avoid configuration errors, ensure your settings adhere to these documented constraints:
- Minimum Bound:
minSize ≥ 1
- Maximum Bound:
minSize ≤ maxSize
If your goal is to minimize idle resource consumption for low-traffic applications, the lowest valid configuration is minSize = 1. Setting both minSize and maxSize to 1 effectively disables concurrency, forcing all database requests to be processed sequentially.
Startup Validation and Low-Traffic Behavior
When testConnectionOnStartup is enabled, c3p0 attempts to establish and validate the number of connections specified by minSize during the application boot sequence. For low-traffic workloads, a minSize of 1 ensures that only one connection is validated at startup, reducing the initial resource footprint on the database server.
Identifying Connection Latency
Reducing minSize can introduce "cold start" latency if the single retained connection times out or is closed by the database. To determine if a reduced pool size is impacting performance, monitor the following metrics:
- Connection Acquisition Time: Measure the delta between the request for a connection and the moment it is granted. A spike in this metric during the first request after a period of inactivity indicates connection establishment overhead.
- Connection Churn Rate: Track the frequency of new connection creations versus reuse. High churn with a low
minSize suggests the pool is constantly destroying and recreating connections.
Verification Steps
Verify your Hibernate properties (typically in hibernate.cfg.xml or application.properties) match the following scoped pattern:
# Correct configuration for minimum resource usage
hibernate.c3p0.min_size=1
hibernate.c3p0.max_size=5
hibernate.c3p0.testConnectionOnStartup=true
Diagnostic Note: Please specify which JDBC driver version you are using, as some drivers have significantly higher connection establishment costs that may make a minSize of 1 impractical regardless of traffic volume.