Question

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.

Was it helpful?

Solution

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();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top