swaldman / c3p0

a mature, highly concurrent JDBC Connection pooling library, with support for caching and reuse of PreparedStatements.
http://www.mchange.com/projects/c3p0
Other
1.28k stars 338 forks source link

minPoolSize of 0 #151

Open azadbolour opened 4 years ago

azadbolour commented 4 years ago

I have an application that is idle most of the time, but may have bursts of activity from time to time. During the times it is idle, I'd like to have 0 connections to the database, so that the database can be quiesced. Using a serverless database like AWS Aurora, I would then only have to pay for minutes that the database is actually active, and save on the cost of operating the database.

Reading the C3P0 configuration documentation it appeared as if a minPoolSize of 0 implies the lack of a minimum, rather than a minimum of 0. Would appreciate confirmation of the meaning of a minPoolSize of 0.

Is there any way to force C3P0 to close every connection it has to the database during an idle period? Incurring the cost of opening connections during bursts of activity is tolerable for my particular use case.

Many thanks.

Azad

swaldman commented 6 months ago

Hi,

c3p0 has a config parameter for this, maxIdleTimeExcessConnections. You can just set this, and minPoolSize to 0, and you should get what you want.