Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to log connection pool data using BoneCP

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.

like image 849
mnowotka Avatar asked Jan 31 '12 12:01

mnowotka


People also ask

How do I monitor connection pooling?

Select the Connection Pooling tab. Ensure that the PerfMon Enable checkbox is checked. Start Performance Monitor by selecting Start → All Programs → Administrative Tools → Performance.

Which pooling connection do you use for connection to database?

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.

What is get pooled connection from DataSource?

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.


1 Answers

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();
like image 189
Clinton Avatar answered Oct 04 '22 12:10

Clinton