server: Fix exception while update domain resource count (#3204)
  reimplement 3204 on moved file in 4.12
diff --git a/engine/schema/src/main/java/com/cloud/configuration/dao/ResourceCountDaoImpl.java b/engine/schema/src/main/java/com/cloud/configuration/dao/ResourceCountDaoImpl.java
index 4bd8302..9b6734d 100644
--- a/engine/schema/src/main/java/com/cloud/configuration/dao/ResourceCountDaoImpl.java
+++ b/engine/schema/src/main/java/com/cloud/configuration/dao/ResourceCountDaoImpl.java
@@ -266,18 +266,18 @@
     }
 
     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);
         }
     }
-
-}
\ No newline at end of file
+}