How to check the Database Connection leakage in Java EE application?

User 1034 picture User 1034 · Jun 19, 2010 · Viewed 22k times · Source

Is there any way to check the connection leakage in a Java EE application?

The application is running on my local machine. It uses a MySQL database and a user enters his details into this database.

In my opinion connection leakage means not closing the connection object properly. I am creating too many database connections in my application. I want to check if there is any connection leakage in the database connections.

Answer

Pascal Thivent picture Pascal Thivent · Jun 19, 2010

log4jdbc, a Java JDBC driver that can log SQL and/or JDBC calls for other JDBC drivers, has a logger which logs connection open and close events as well as dumping all open connection numbers. This is very useful for hunting down connection leak problems.

Another tool that you might want to check is ConnLeakFinder, a simple tool to pinpoint jdbc connection leaks in java code. I don't have any experience with it though.