coverity 1116562: resource count resource leak

This commit is contained in:
Daan Hoogland 2015-07-28 17:23:44 +02:00
parent 49cb56bbca
commit 168199360d

View File

@ -280,14 +280,13 @@ public class Upgrade420to421 implements DbUpgrade {
private static void upgradeResourceCountforDomain(Connection conn, Long domainId, String type, Long resourceCount) throws SQLException {
//update or insert into resource_count table.
PreparedStatement pstmt = null;
pstmt =
conn.prepareStatement("INSERT INTO `cloud`.`resource_count` (domain_id, type, count) VALUES (?,?,?) ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id), count=?");
pstmt.setLong(1, domainId);
pstmt.setString(2, type);
pstmt.setLong(3, resourceCount);
pstmt.setLong(4, resourceCount);
pstmt.executeUpdate();
pstmt.close();
String sqlInsertResourceCount = "INSERT INTO `cloud`.`resource_count` (domain_id, type, count) VALUES (?,?,?) ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id), count=?";
try (PreparedStatement pstmt = conn.prepareStatement(sqlInsertResourceCount);) {
pstmt.setLong(1, domainId);
pstmt.setString(2, type);
pstmt.setLong(3, resourceCount);
pstmt.setLong(4, resourceCount);
pstmt.executeUpdate();
}
}
}