Monitoring Bone cp Connection Pool

We are trying to go to the bonecp connection pool with c3p0. we use hibernate as an ORM tool.

Now, is there a way to track connections in boncecp, how do I find out the maximum available and busy connection in the pool at a specific point in time, and are there any unsettled connections to the pool, etc.?

thanks for the help

+8
java hibernate connection-pooling connection bonecp
source share
1 answer

A lot of monitoring information is available through the BoneCP connection pool class ( BoneCP ). This is registered as a managed bean, so if you are using jconsole or some other monitoring tool, you should get a detailed overview of this information, for example:

BoneCP MBean Screenshot

If necessary, you can get an instance of BoneCP from 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; } 
+7
source share

All Articles