加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 如何监视c3p0连接

发布时间:2020-12-14 16:35:47 所属栏目:Java 来源:网络整理
导读:我在JBoss战争中使用Hibernate,使用c3p0进行连接池,都在我的类路径中的一个hibernate.cfg.xml配置文件中配置 property name="connection.provider_class"org.hibernate.connection.C3P0ConnectionProvider/property 我看到server.log生成有关连接池的有趣信
我在JBoss战争中使用Hibernate,使用c3p0进行连接池,都在我的类路径中的一个hibernate.cfg.xml配置文件中配置
<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>

我看到server.log生成有关连接池的有趣信息的行:

DEBUG [com.mchange.v2.resourcepool.BasicResourcePool] trace com.mchange.v2.resourcepool.BasicResourcePool@63f5e4b6 [managed:10,unused:9,excluded:0]

对于我的监控池(我使用nagios),我想提供一个JSP,告诉我们正在使用多少个连接,以及有多少个连接是空的,正如日志文件所说.

如何问c3p0有多少管理和未使用的连接?

解决方法

您可以通过 JMX监视连接池.从文档中:

07001

If JMX libraries and a JMX
MBeanServer are available in your
environment (they are include in JDK
1.5 and above),you can inspect and configure your c3p0 datasources via a
JMX administration tool (such as
jconsole,bundled with jdk 1.5). You
will find that c3p0 registers MBeans
under com.mchange.v2.c3p0,one with
statistics about the library as a
whole (called C3P0Registry),and an
MBean for each PooledDataSource you
deploy. You can view and modify your
DataSource’s configuration properties,
track the activity of Connection,
Statement,and Thread pools,and reset
pools and DataSources via the
PooledDataSource MBean. (You may
wish to view the API docs of
07002 for
documentation of the available
operations.)

顺便说一下,Nagios似乎有JMX插件,你不会被迫使用JSP.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读