mirror of https://github.com/apache/cloudstack.git
server: Fix exception while update domain resource count (#3204)
This commit is contained in:
parent
96611fc640
commit
b60daf7142
|
|
@ -276,17 +276,18 @@ public class ResourceCountDaoImpl extends GenericDaoBase<ResourceCountVO, Long>
|
|||
}
|
||||
|
||||
private long executeSqlCountComputingResourcesForAccount(long accountId, String sqlCountComputingResourcesAllocatedToAccount) {
|
||||
try (TransactionLegacy tx = TransactionLegacy.currentTxn()) {
|
||||
TransactionLegacy tx = TransactionLegacy.currentTxn();
|
||||
try {
|
||||
PreparedStatement pstmt = tx.prepareAutoCloseStatement(sqlCountComputingResourcesAllocatedToAccount);
|
||||
pstmt.setLong(1, accountId);
|
||||
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (!rs.next()) {
|
||||
throw new CloudRuntimeException(String.format("An unexpected case happened while counting allocated computing resources for account: " + accountId));
|
||||
return 0L;
|
||||
}
|
||||
return rs.getLong("total");
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue