What is a connection leak, and how can we fix it in Java?
A connection leak implies a portion of the information base request/transaction are not getting shut as expected or are not getting committed. Lastly, those connections are getting abandoned and shut down all time.
To fix the leaks, you have to find where you have used the opening connections and then use try-with-resources that will do all the close() stuff for you.
BY Best Interview Question ON 03 May 2022
Example
try (Connection connection = DriverManager.getConnection(url);
PreparedStatement statement = createPreparedStatement(connection);
ResultSet resultSet = statement.executeQuery()) {
// process the resultSet here, all resources will be cleaned up }