Announcement Announcement Module
No announcement yet.
Database Connection Pool Statistics/Monitoring via JMX Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Database Connection Pool Statistics/Monitoring via JMX

    I would like to be able to monitor a database connection pool via JMX. c3p0 has some methods you can call given a PooledDataSource to find out how many connections are available, in use, and idle. What would be the easiest way to expose those statistics?

  • #2
    Spring, with version 1.2, has really nice support for JMX. See the manual at . For instance, you can easily expose beans as MBeans.


    • #3
      C3P0 Hibernate JMX MBean

      To get C3P0 MBeans use the latest C3P0 version (pre11) or higher. They are auto registered and you don't need to register them with Spring.

      To get Hibernate MBeans configure your context XML file like:
      <!-- JMX Configuration { -->
      <bean id="mbeanExporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
         <property name="server" ref="mbeanServerFactory"/>
         <property name="beans">
               <entry key="org.hibernate:name=Statistics"  value-ref="hibernateMBean"/>
      <bean id="mbeanServerFactory" class="">
          <property name="locateExistingServerIfPossible" value="true"/>
      <bean id="hibernateMBean" class="org.hibernate.jmx.StatisticsService">
         <property name="sessionFactory" ref="sessionFactory"/>
         <property name="statisticsEnabled" value="true"/>
      <!-- } JMX Configuration-->