I'm getting the following issue from Sonar: SampleDao.java null Use try-with-resources or close this "PreparedStatement" in a "finally" clause.
And I'm using Spring JDBC with the following code:
ResponseObject user = jdbcTemplate.query(new PreparedStatementCreator() {
@Override
public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
PreparedStatement ps = con.prepareStatement(MY_QUERY);
ps.setLong(1, parameter);
return ps;
}
}, new MyResultSetExtractor());
My question is that I think I don't need to close the connection because I have a connection pool, so what do you think I have to do, just ignore the sonar issue ? or is there anything else I can do?.
Thank you