Program: 89532
Project: 89532
Buggy source:
private void updateUserStats(Connection conn){
  try {
    PreparedStatement pstmt=conn.prepareStatement("String_Node_Str");
    pstmt.executeUpdate();
    pstmt.close();
    s_logger.debug("String_Node_Str");
    pstmt=conn.prepareStatement("String_Node_Str");
    ResultSet rs=pstmt.executeQuery();
    while (rs.next()) {
      Long id=rs.getLong(1);
      Long accountId=rs.getLong(2);
      Long dataCenterId=rs.getLong(3);
      pstmt=conn.prepareStatement("String_Node_Str");
      pstmt.setLong(1,dataCenterId);
      ResultSet dcSet=pstmt.executeQuery();
      if (!dcSet.next()) {
        s_logger.error("String_Node_Str");
        throw new CloudRuntimeException("String_Node_Str");
      }
      String dataCenterType=dcSet.getString(1);
      if (dataCenterType.equalsIgnoreCase("String_Node_Str")) {
        accountId=1L;
      }
      pstmt=conn.prepareStatement("String_Node_Str");
      pstmt.setLong(1,accountId);
      pstmt.setLong(2,dataCenterId);
      ResultSet rs1=pstmt.executeQuery();
      if (!rs1.next()) {
        pstmt=conn.prepareStatement("String_Node_Str");
        pstmt.setLong(1,accountId);
        pstmt.setLong(2,dataCenterId);
        ResultSet nonRemovedVms=pstmt.executeQuery();
        if (nonRemovedVms.next()) {
          s_logger.error("String_Node_Str");
          throw new CloudRuntimeException("String_Node_Str");
        }
 else {
          s_logger.debug("String_Node_Str" + accountId + "String_Node_Str");
          continue;
        }
      }
      Long deviceId=rs1.getLong(1);
      pstmt=conn.prepareStatement("String_Node_Str");
      pstmt.setLong(1,deviceId);
      pstmt.setLong(2,id);
      pstmt.executeUpdate();
      pstmt=conn.prepareStatement("String_Node_Str");
    }
    s_logger.debug("String_Node_Str");
  }
 catch (  Exception e) {
    throw new CloudRuntimeException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
private void updateUserStats(Connection conn){
  try {
    PreparedStatement pstmt=conn.prepareStatement("String_Node_Str");
    pstmt.executeUpdate();
    pstmt.close();
    s_logger.debug("String_Node_Str");
    pstmt=conn.prepareStatement("String_Node_Str");
    ResultSet rs=pstmt.executeQuery();
    while (rs.next()) {
      Long id=rs.getLong(1);
      Long accountId=rs.getLong(2);
      Long dataCenterId=rs.getLong(3);
      pstmt=conn.prepareStatement("String_Node_Str");
      pstmt.setLong(1,dataCenterId);
      ResultSet dcSet=pstmt.executeQuery();
      if (!dcSet.next()) {
        s_logger.error("String_Node_Str");
        throw new CloudRuntimeException("String_Node_Str");
      }
      String dataCenterType=dcSet.getString(1);
      if (dataCenterType.equalsIgnoreCase("String_Node_Str")) {
        accountId=1L;
      }
      pstmt=conn.prepareStatement("String_Node_Str");
      pstmt.setLong(1,accountId);
      pstmt.setLong(2,dataCenterId);
      ResultSet rs1=pstmt.executeQuery();
      Long deviceId=0L;
      if (!rs1.next()) {
        pstmt=conn.prepareStatement("String_Node_Str");
        pstmt.setLong(1,accountId);
        pstmt.setLong(2,dataCenterId);
        ResultSet nonRemovedVms=pstmt.executeQuery();
        if (nonRemovedVms.next()) {
          s_logger.warn("String_Node_Str" + accountId + "String_Node_Str"+ dataCenterId+ "String_Node_Str");
          pstmt=conn.prepareStatement("String_Node_Str");
          pstmt.setLong(1,accountId);
          pstmt.setLong(2,dataCenterId);
          ResultSet userVmSet=pstmt.executeQuery();
          if (!userVmSet.next()) {
            s_logger.warn("String_Node_Str" + accountId + "String_Node_Str"+ dataCenterId);
            continue;
          }
          deviceId=userVmSet.getLong(1);
        }
 else {
          s_logger.debug("String_Node_Str" + accountId + "String_Node_Str");
          continue;
        }
      }
 else {
        deviceId=rs1.getLong(1);
      }
      pstmt=conn.prepareStatement("String_Node_Str");
      pstmt.setLong(1,deviceId);
      pstmt.setLong(2,id);
      pstmt.executeUpdate();
      pstmt=conn.prepareStatement("String_Node_Str");
    }
    s_logger.debug("String_Node_Str");
  }
 catch (  Exception e) {
    throw new CloudRuntimeException("String_Node_Str",e);
  }
}