9

We are trying to move to bonecp connection pool from c3p0. we use hibernate as the ORM tool.

Now, is there any way to monitor the connections in boncecp like getting to know the maximum available and busy connection in the pool at a particular point of time and whether there are any unreturned connections to the pool etc?

Thanks for the help

Npa
  • 617
  • 2
  • 15
  • 26

1 Answers1

7

A lot of monitoring information is accessible via the BoneCP connection pool class (BoneCP). This is registered as a managed bean, so if you use jconsole or some other monitoring tool you should get a detailed view to this information, e.g.:

BoneCP MBean Screenshot

If needed you can get the BoneCP instance from a BoneCPDataSource using BoneCPDataSource#getPool():

/**
 * Get a status information of the JDBC connections.
 * 
 * @return The status information of the JDBC connections.
 */
public String getConnectionStatus() {
    String status = "unknown";
    if (dataSource instanceof BoneCPDataSource) {

        BoneCPDataSource bcpDataSource = (BoneCPDataSource) dataSource;
        BoneCP bcp = bcpDataSource.getPool();
        status = "JDBC connections: " + bcp.getTotalLeased()
            + " in use / " + bcp.getTotalFree()
            + " in pool / total created "
            + bcp.getTotalCreatedConnections();

    }
    return status;
}
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
FrVaBe
  • 47,963
  • 16
  • 124
  • 157