I am modifying my application code to comply with the pmd rules. I had a Close Resource error in this code:
Connection c = DataSourceUtils.getConnection(dataSource);
Statement request = null;
try {
request = c.createStatement();
request.execute(loadDataRequest);
} catch (SQLException e) {
dataLogger.error(e);
throw e;
}
So, I searched and found apache utility to avoid it: DButils My code became like this
Connection c = DataSourceUtils.getConnection(dataSource);
Statement request = null;
try {
request = c.createStatement();
request.execute(loadDataRequest);
} catch (SQLException e) {
dataLogger.error(e);
throw e;
} finally {
DbUtils.closeQuietly(request);
DbUtils.closeQuietly(c);
}
However, I still have a PMD warning in eclipse and sonar reports! Do you have any ideas how to fix this forever?
source
share