Announcement Announcement Module
No announcement yet.
How to monitor current size of connection pool Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to monitor current size of connection pool

    I am getting pool exhausted exceptions and wanted to know if I have a connection leak.

    Is there a way I can monitor the current number of connections in the pool, which of them are idle, which are used -- while the application is running?

    Tangentially, I'm using MS-SQL server so if you know of a way to do something like a select from v$session (oracle) equivalent that would be great too

  • #2
    I found a solution to this..

    Due to my branded oem jdbc driver, it requires a username/password to unlock. In order for me to do that I had to create a delegateDataSource.

    Here I was able to monitor the datasource with the following code:

        private void monitorConnections() {
            if (logger.isDebugEnabled()) {
                if (getTargetDataSource() instanceof BasicDataSource) {
                    BasicDataSource basicDs = (BasicDataSource)getTargetDataSource();
                    logger.debug("Number of idle connections: " + basicDs.getNumIdle());
                    logger.debug("Number of active connections: " + basicDs.getNumActive());
                } else {
                    logger.warn("Unable to monitor non-dbcp commons data source");
    I also found the source to my connection leak!


    • #3
      You can try also to use JMX - it's a very nice alternative which you can use in production and the overhead is neglijible.