0

I have missing about close PreparedStatement in code. I want to find all function same problem => How to setting warning missing release resource in eclipse? I try to Window -> Preference -> Java -> Compiler -> Errors/Warning -> Resource Leak but it not active.

 private void insertData(String userName)
        throws SQLException {
    PreparedStatement ps = null;
    ps = con.prepareStatement(INSERT_DATA);
    ps.setString(1, userName);
    // SQL execution
    ps.executeUpdate();

}

Thank all

1 Answers1

0

I tried your example code. I think you have to set the potential resource leak to warning or error to see the PreparedStatement issues you like to find.

this is because a PreparedStatement might be closed when the connection is closed.

See a discussion about that here: Must JDBC Resultsets and Statements be closed separately although the Connection is closed afterwards?

Sorontur
  • 500
  • 4
  • 15