<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有多少管理和未使用的连接?
解决方法
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
undercom.mchange.v2.c3p0
,one with
statistics about the library as a
whole (calledC3P0Registry
),and an
MBean for eachPooledDataSource
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.