tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amit shah <>
Subject Closing tomcat jdbc connection pool
Date Fri, 02 Mar 2012 06:23:45 GMT
          I am using the tomcat7 jdbc pool independently by deploying the
jdbc pool and juli jars with my web application. I would like to get
suggestions on how to close the connection pool when the application server
is stopped.
          The below code doesn't work as expected

        public void shutdown(DataSource dataSource) {
                org.apache.tomcat.jdbc.pool.DataSource tomcatDataSource =
                try {
                   tomcatDataSource =
                } catch (SQLException e) {
                   throw new RuntimeException(e);

        The reason being the unwrap implementation
in org.apache.tomcat.jdbc.pool.DataSource returns null. Hence a NPE.
        Casting the dataSource instance to
directly org.apache.tomcat.jdbc.pool.DataSource isn't an option because
during creation we decorate the data source for various reasons like
logging, changing the isolation level etc.

Any ideas on how could the close method be called?

Thank you.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message