Java code to get lost active DB Connection back to

2019-08-26 20:44发布

问题:

I am facing connection leakage problem with DBCP2.

I went though all the code base and have closed/released the connections wherever required.

I have also run Sonar, but no connection leakages were reported.

Finally I have decide to write a java based executor service which will close or return the DB connections back to the pool periodically. The service should run once in 2 days.

Can someone help with the code to close the connections which are not returned to pool?