Get number of free connections in connection pool

sinuhepop picture sinuhepop · Dec 14, 2009 · Viewed 8.7k times · Source

In my project Spring manages connection pool with org.apache.commons.dbcp.BasicDataSource class. Is possible to get how many connections are free or used in current time?

Thanks.

Answer

user7094 picture user7094 · Dec 14, 2009

From the javadocs, you should be able to read this from the getNumIdle() and getNumActive() methods, if you can get an instance of the BasicDataSource.