Announcement Announcement Module
Collapse
No announcement yet.
Database Connection Pool Statistics/Monitoring via JMX Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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 http://www.springframework.org/docs/...2RC2/ch20.html . For instance, you can easily expose beans as MBeans.

    Comment


    • #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:
      Code:
      <!-- JMX Configuration { -->
      <bean id="mbeanExporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
         <property name="server" ref="mbeanServerFactory"/>
         <property name="beans">
            <map>
               <entry key="org.hibernate:name=Statistics"  value-ref="hibernateMBean"/>
            </map>
         </property>
       </bean>
      
      <bean id="mbeanServerFactory" class="org.springframework.jmx.support.MBeanServerFactoryBean">
          <property name="locateExistingServerIfPossible" value="true"/>
      </bean>
      
      <bean id="hibernateMBean" class="org.hibernate.jmx.StatisticsService">
         <property name="sessionFactory" ref="sessionFactory"/>
         <property name="statisticsEnabled" value="true"/>
      </bean>
      <!-- } JMX Configuration-->

      Comment

      Working...
      X