简体   繁体   中英

Monitoring Bone cp Connection pool

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

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, eg:

BoneCP MBean截图

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM