Monitoring for Commons DBCP?
===

A huge webapp in my Tomcat sometimes starts using too many DBCP connections, leading to problems.  
To investigate, I want to know precisely at each point in time what thread/method is holding each connection of the pool. Does not need to be real-time, post-mortem analysis is OK.

I have been looking for such a DBCP monitoring tool, in vain, so I am about to write mine.  
*(if there is any interest I can make it open source)*

Here is my plan:

- Modify [PoolingDataSource.getConnection][1] to log "`DBCP+1 <thread-id>`"
- Modify [DelegatingConnection.close][2] to log "`DBCP-1 <thread-id>`"
- Write a small script to generate this simple CSV for visualization:

![enter image description here][3]

QUESTION:  
Am I missing some Commons-DBCP concept that makes the idea invalid?  
Or am I re-inventing the wheel?


  [1]: http://grepcode.com/file/repo1.maven.org/maven2/commons-dbcp/commons-dbcp/1.4/org/apache/commons/dbcp/PoolingDataSource.java#PoolingDataSource.getConnection%28%29
  [2]: http://grepcode.com/file/repo1.maven.org/maven2/commons-dbcp/commons-dbcp/1.4/org/apache/commons/dbcp/DelegatingConnection.java#DelegatingConnection.close%28%29
  [3]: http://i.stack.imgur.com/saODi.png