I ran findbugs on our code base, and he pointed out that there are two more statements that still need to be closed. In this section of code, we run:
preparedStatement = connection.prepareStatement(query);
for three different queries, reusing the prepared state. In the finally block, we close the resource:
finally{ try{ if (resultSet != null) resultSet.close(); } catch (Exception e) { exceptionHandler.ignore(e); } try { if (preparedStatement != null) preparedStatement.close(); } catch(Exception e) { exceptionHandler.ignore(e); }
If the statement should be closed before the next connection .prepareStatement (query); or is it a suspicious search?
java prepared-statement findbugs
Ann addicks
source share