如何使用BoneCP记录连接池数据

时间:2022-09-27 20:51:18

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.

有没有人知道使用BoneCP来记录连接池数据(即打开和空闲数据库连接的数量)?使用我正在迁移的C3P0很容易实现(实际上默认情况下会记录此信息)但是看起来很难获得唱歌BoneCP。现在我在日志中看到的是原始SQL语句。

1 个解决方案

#1


5  

Use the Statistics class. For example: ...set up BoneCP connectionPool object

使用Statistics类。例如:...设置BoneCP connectionPool对象

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();

#1


5  

Use the Statistics class. For example: ...set up BoneCP connectionPool object

使用Statistics类。例如:...设置BoneCP connectionPool对象

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();