Is there a way to programatically ask c3p0 how many of it's connections are being used, or perhaps logs when the pool is exhausted.
As indicated in the URL referenced by Austin's comment above, you can use JMX to inspect and modify running c3p0 PooledDataSources.
You can also do so programmatically. c3p0's PooledDataSources have an elaborate API for inspecting their state:
http://www.mchange.com/projects/c3p0/apidocs/com/mchange/v2/c3p0/PooledDataSource.html
If you are using ComboPooledDataSource, you have access to an even richer API.
http://www.mchange.com/projects/c3p0/apidocs/com/mchange/v2/c3p0/ComboPooledDataSource.html
I hope this helps!
来源:https://stackoverflow.com/questions/12725508/asking-c3p0-how-many-connections-are-in-use