/**
   * @author gdulski
   * @since nov 26, 2003
   * @param ArrayList of updated CustomerValue objects containing new PIN, new OptInStatus, new date
   *     updated and new lastUpdateUserId.
   * @return boolean true if update successful otherwise return false
   *     <p>Update the DAOptInCustomer table in Styx for each customer in the input ArrayList.
   */
  protected boolean updateCustomers(ArrayList _rowset) throws OptInCustomerException {
    boolean updateOK = false;

    // dB connection
    init();
    // update each customer
    for (int _inx = 0; _inx < _rowset.size(); _inx++) {
      CustomerValue _customer = (CustomerValue) _rowset.get(_inx);
      try {
        updateOK = update(_customer);
        if (!updateOK) break;
      } catch (SQLException _e) {
        AppLog.writeErrorLog(
            "SQL Exception when preparing update SQL "
                + _customer.getCAPnumber()
                + " message : "
                + _e.getMessage());
        System.out.println(
            "SQL Exception when preparing update SQL "
                + _customer.getCAPnumber()
                + " msg "
                + _e.getMessage());
        throw new OptInCustomerException(
            "SQL Exception when preparing update SQL "
                + _customer.getCAPnumber()
                + " msg "
                + _e.getMessage());
      }
      _customer = null;
    }
    return true;
  }
  /**
   * @author gdulski
   * @param _customer CustomerValue object
   * @return boolean true if update ok otherwise false
   * @throws SQLException
   * @throws OptInCustomerException
   *     <p>Update the DAOptInCustomer table Process a single customer at a time. Get the update SQL
   *     from the CAPBatch properties file
   *     <p>Columns affected: OptInKey, OptInStatus, LastStatusUpdateDt, LastUpdateDt,
   *     LastUpdateUserID
   */
  private boolean update(CustomerValue _customer) throws SQLException, OptInCustomerException {
    boolean updateOK = false;

    // prepare the SQL
    if (_stmt == null) {
      _stmt = _con.prepareStatement(_updatesql);
    }

    // populate query parameters
    try {
      _stmt.setString(1, _customer.getOptInKey());
    } catch (SQLException _s1) {
      _s1.printStackTrace();
      System.out.println("OptInKey exception " + _s1.getMessage());
    }
    try {
      if (_customer.getOptInStatus().equalsIgnoreCase(DEFAULTOPTINSTATUSCODE)) {
        _stmt.setString(2, DEFAULTOPTINSTATUSCODE);
      } else {
        _stmt.setString(2, refreshedOptInStatusCode.trim());
      }
    } catch (SQLException _s1) {
      _s1.printStackTrace();
      System.out.println("OptInStatus exception " + _s1.getMessage());
    }
    try {
      _stmt.setString(3, _customer.getLastUpdateUserid().substring(0, 19));
    } catch (SQLException _s1) {
      _s1.printStackTrace();
      System.out.println("LastUpdateUserId exception " + _s1.getMessage());
    }
    try {
      _stmt.setString(4, _customer.getCAPnumber());
    } catch (SQLException _s1) {
      _s1.printStackTrace();
      System.out.println("CAPnumber exception " + _s1.getMessage());
    }

    // execute the stmt
    try {
      _stmt.executeUpdate();
      _stmt.close();
      _stmt = null;
      updateOK = true;
    } catch (SQLException _e) {
      AppLog.writeErrorLog(
          "SQL EXCEPTION occurred update customer "
              + _customer.getCAPnumber()
              + " message\n"
              + _e.getMessage());
      System.out.println(
          "SQL EXCEPTION occurred update customer "
              + _customer.getCAPnumber()
              + " message\n"
              + _e.getMessage());
      throw new OptInCustomerException(
          "SQL EXCEPTION occurred update customer "
              + _customer.getCAPnumber()
              + " message\n"
              + _e.getMessage());
    }
    if (_customer.getOptInStatus().equalsIgnoreCase(DEFAULTOPTINSTATUSCODE)) {
      // Audit Trail the Warning letter.
      DAAuditDetails da = new DAAuditDetails();
      da.setApplicationID(
          _appProp.getProperty("batch.audittrail.optincustomerletter.ApplicationID"));
      System.out.println("Set Application ID:" + da.getApplicationID());
      da.setLogAccess(null);
      da.setLogAction(_appProp.getProperty("batch.audittrail.optincustomerletter.Action"));
      da.setLogAdminName(0);
      da.setLogCAPNumber(_customer.getCAPnumber());
      da.setLogProgram("");
      da.setLogUserName(0);
      AuditTrail at = new AuditTrail();
      at.writeAuditLog(da);
    }
    return updateOK;
  }