We have a system where data is partitioned by date.
So, for example, in SqlServer we have one database per month of data. Each month partition uses a Jdbc driver Datasource wrapped in a C3P0 connection pool DataSource
.
After a period of time the date range of the partition becomes old enough that we want to offline it. In that case we just remove the relevant month's DataSource
from the available list.
However, ideally, when offlining I would like to "close" the DataSource
so the pool relinquishes all connections to the DB.
DataSource
has no close method for me to call so I'm not sure how to clean this up.
Any suggestions?
You don't close a DataSource
- you close the connection returned by a DataSource
. The DataSource
itself is never "open" as such.
I would expect the pool to relinquish open connections after a time-out anyway, so I suggest you just don't worry about it :) If you need to forcibly close the connections, you'll need to keep a reference to the connection pool itself and use any facilities supplied by c3p0 directly.