获取连接池中的空闲连接数

获取连接池中的空闲连接数

本文介绍了获取连接池中的空闲连接数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,Spring使用org.apache.commons.dbcp.BasicDataSource类管理连接池。是否可以获得当前时间内有多少个免费或使用的连接?

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?

谢谢。

推荐答案

从javadocs,您应该能够从和方法,如果你能得到BasicDataSource的实例。

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.

这篇关于获取连接池中的空闲连接数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 19:31