I have a JSP/Servlet based application, the database team is complaining about the increase in open database connection.I suspect that the connection is not closed after use.
I want to make some code changes by initializing the connection string in try catch block as suggested in Java 8
I have tried closing the connection in final block which is working fine
here is the code i want to implement , Will this fix the issue?Is there any other way to close the open connections after use with little code change?
try(Connection con = DBConnectivity.openConnectionThread();
PreparedStatement ps1 = con.prepareStatement(sql1)) {
-----
------
}