Does anyone know hot to log connection pool data (i.e. number of open and idle db connections) using BoneCP? It's easy to achieve using C3P0 which I'm migrating from (in fact this information is logged by default there) but it seems to be harder to get sing BoneCP. For now what I see in logs is raw SQL statements.
Select the Connection Pooling tab. Ensure that the PerfMon Enable checkbox is checked. Start Performance Monitor by selecting Start → All Programs → Administrative Tools → Performance.
Connection pooling enables the idle connection to be used by some other thread to do useful work. In practice, when a thread needs to do work against a MySQL or other database with JDBC, it requests a connection from the pool.
Getting and Using Pooled Connections. A connection pool is a cache of database connection objects. The objects represent physical database connections that can be used by an application to connect to a database. At run time, the application requests a connection from the pool.
Use the Statistics class. For example: ...set up BoneCP connectionPool object
Statistics stats = connectionPool.getStatistics() (previously getStats but later renamed)
return
"Tot Conn Created: " + stats.getTotalCreatedConnections() +
"Tot Free Conn: " + stats.getTotalFree() +
"Tot Leased Conn: " + stats.getTotalLeased();
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