使用SonarCloud
我得到了这个错误:
Use try-with-resources or close this "ResultSet" in a "finally" clause
这是以下代码:
public long executeUpdate() throws SQLException {
if (query != null) {
try {
statement.execute();
if (returnGeneratedKeys) {
ResultSet resultSet = statement.getGeneratedKeys();
if (resultSet.next()) {
return resultSet.getLong(1);
}
}
} finally {
statement.close();
connection.close();
}
}
return 0;
}