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
Using VisualVM to Monitor Database Performance. VisualVM provides information about database transactions and connection pooling. To see connection pooling information, you should install the Java M-Beans plugin for your version of VisualVM. See the VisualVM documentation for more information on M-Beans plugin.
One of the most common issues undermining connection pool benefits is the fact that pooled connections can end up being stale. This most often happens due to inactive connections being timed out by network devices between the JVM and the database. As a result, there will be stale connections in the pool.
For optimal performance, use a pool with eight to 16 connections per node. For example, if you have four nodes configured, then the steady-pool size must be set to 32 and the maximum pool size must be 64.
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.:
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With