user3813256
user3813256

Reputation:

warning messages with hikaricp

I am using hikaricp as my database connection pool. I am closing the connection when I am done with my SQL statement by calling close on the connection which I believe you should return the connection proxy back to the pool . Yet, I see the following warning (not error) message and I have to wonder whether its an issue that needs to be addressed because I'm not cleaning up my connection resources properly. I am not using a try with resources but using a try catch finally (I close the connection in the finally & I realize that in certain conditions, the finally may actually not get called but it is being called in my case). any thoughts?

2014-09-15 13:59:26,083 WARN c.z.h.p.LeakTask [Hikari Housekeeping Timer (pool wmHikariCp)] Connection leak detection triggered, stack trace follows java.lang.Exception
    at com.abc.test.DBConnPool.getConnection(DBConnPool.java:71)
    at com.abc.test.TestProj.callDB(TestApp.java:30)
    at com.abc.test.TestProj.main(TestApp.java:81)

Upvotes: 1

Views: 3014

Answers (2)

ali haider
ali haider

Reputation: 20252

Can you confirm whether you are indeed releasing the connection back to the pool? Can you use try with resources (in addition to increasing threshold as Brett mentioned):

try (Connection conn = DBConnectionPool.getConnection(); 
        PreparedStatement ps = conn.prepareStatement(preparedQuery);) {

and the resultset (because some drivers/databases may not clean out resultset when connection is cleaned though not sure if this is still valid for new drivers/databases but I'm not sure what you are using):

    try (ResultSet rs = ps.executeQuery();) {

Hope it helps.

Upvotes: 1

brettw
brettw

Reputation: 11114

There is a possibility that you are merely using the connection longer than the leak detection timeout. The leak detection is a threshold for how long a connection is out of the pool. Try increasing the threshold to a longer timeout.

Upvotes: 0

Related Questions