- status: open --> closed
- assigned_to: Andreas Dangel
- Milestone: New Tickets --> PMD-5.1.0
The following code will catch the CheckResultSet warning
try {
PreparedStatement ps = getCurrentSession().connection().prepareStatement(query);
ps.setInt(1, fiscalYear);
ResultSet rs = ps.executeQuery();
rs.next();
result = rs.getInt("value");
} catch (SQLException se) {
throw new DataAccessException(se);
}
return result
The following code will ignore the CheckResultSet warning
PreparedStatement ps = null
ResultSet rs = null;
try {
ps = getCurrentSession().connection().prepareStatement(query);
ps.setInt(1, fiscalYear);
rs = ps.executeQuery();
rs.next(); //this should be a PMD warning, but it is not
result = rs.getInt("value");
} catch (SQLException se) {
throw new DataAccessException(se);
} finally {
//call method to close the ResultSet and PreparedStatment
}
return result