Monitoring C3P0 Connection Pools with Dynatrace using JMX

What is C3P0?

C3P0 is a Java library that helps manage database connections efficiently by using a connection pool.

Imagine you're at a library where people keep asking the librarian for books (connections). Instead of going to the warehouse every time, the librarian keeps popular books on a shelf (a pool) so people can grab them quickly and return them later. That’s what C3P0 does with database connections!

Why Use C3P0?

  • Automatically reuses and manages connections
  • Handles timeouts, connection leaks, and slow queries gracefully
  • Exposes internal metrics via JMX, enabling tools like Dynatrace to monitor it

Similar Connection Pool Libraries

Library Highlights
HikariCP Super fast, lightweight, used by Spring Boot by default. Great performance.
Apache DBCP Mature and stable, widely used in legacy apps.
Tomcat JDBC Pool Supports advanced pooling features and JMX. Used in Tomcat.
Vibur DBCP Low-latency, lightweight alternative to heavier pools.
C3P0 Easy to configure with built-in JMX support.

1. Enable JMX in Spring Boot

Add the following in your application.properties:

spring.jmx.enabled=true

Ensure you set JVM options to expose JMX (especially on servers):

java -Dcom.sun.management.jmxremote \
  -Dcom.sun.management.jmxremote.port=9010 \
  -Dcom.sun.management.jmxremote.rmi.port=9011 \
  -Dcom.sun.management.jmxremote.local.only=false \
  -Dcom.sun.management.jmxremote.authenticate=false \
  -Dcom.sun.management.jmxremote.ssl=false \
  -Djava.rmi.server.hostname=127.0.0.1 \
  -jar yourApp.jar --spring.jmx.enabled=true

2. Explore MBeans Using jmxterm

Download jmxterm:

wget https://repo1.maven.org/maven2/org/cyclopsgroup/jmxterm/1.0.1/jmxterm-1.0.1-uber.jar -O jmxterm.jar

Install and launch jmxterm:

java -jar jmxterm.jar

Open the JMX port:

open localhost:9010

Discover All Available Domains

domains

You will see domains like:

  • java.lang
  • com.sun.management
  • com.mchange.v2.c3p0

List All Beans in a Domain

beans -d java.lang
beans -d com.mchange.v2.c3p0

Inspect a Bean’s Attributes

info -b com.mchange.v2.c3p0:name=...,type=PooledDataSource

Or list readable attributes directly:

get -b com.sun.management:type=OperatingSystem

3. Go to Dynatrace → Extension and Search C3P0

Add the Connection Pools: C3P0 extension to your environment

Add the extension to your environment and configure it to your host or hostgroup.

Final Result

Once setup is complete, you will see:

C3P0 Dynatrace Output
  • Live C3P0 pool metrics on Dynatrace dashboards
  • Pool usage over time
  • Alerting on pool exhaustion using metric thresholds

Tips: Always test JMX connectivity locally before production, and secure your JMX port.