/*
 * @(#)BatchUpdateException.java	1.7 98/05/08
 *
 * Copyright 1998 by Sun Microsystems, Inc.,
 * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of Sun Microsystems, Inc. ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with Sun.
 */

package java.sql;

/**
 *  JDBC 2.0
 *
 *  <P>The BatchUpdateException class provides information on an error that
 *  occurs during a batch update operation.  In addition to the information
 *  provided by SQLException, a BatchUpdateException provides the update
 *  counts for all commands that were executed successfully during the
 *  batch update, i.e. all commands that were executed before the error 
 *  occurred.  The order of elements in an array of update counts
 *  corresponds to the order in which commands were added to the batch.
 */

public class BatchUpdateException extends SQLException {

  /**
   * Construct a fully specified BatchUpdateException.
   *
   * @param reason a description of the warning 
   * @param SQLState an XOPEN code identifying the warning
   * @param vendorCode a database vendor specific warning code
   * @param updateCounts an array of update counts
   */
  public BatchUpdateException( String reason, String SQLState, int vendorCode, 
			       int[] updateCounts ) {
    super(reason, SQLState, vendorCode);
    this.updateCounts = updateCounts;
  }

  /**
   * Construct a BatchUpdateException with a reason and SQLState;
   * vendorCode defaults to 0.
   *
   * @param reason a description of the exception 
   * @param SQLState an XOPEN code identifying the exception 
   * @param updateCounts an array of update counts
   */
  public BatchUpdateException(String reason, String SQLState, 
			      int[] updateCounts) {
    super(reason, SQLState);
    this.updateCounts = updateCounts;
  }

  /**
   * Construct a BatchUpdateException with a reason; SQLState defaults to
   * null and vendorCode defaults to 0.
   *
   * @param reason a description of the exception 
   * @param updateCounts an array of update counts
   */
  public  BatchUpdateException(String reason, int[] updateCounts) {
    super(reason);
    this.updateCounts = updateCounts;
  }

  /**
   * Construct a BatchUpdateException; reason defaults to null, SQLState
   * defaults to null and vendorCode defaults to 0.
   *
   * @param updateCounts an array of update counts
   */
  public BatchUpdateException(int[] updateCounts) {
    super();
    this.updateCounts = updateCounts;
  }

  /**
   * Construct a BatchUpdateException; reason defaults to null, SQLState
   * defaults to null and vendorCode defaults to 0.  UpdateCounts is null.
   *
   */
  public BatchUpdateException() {
    super();
    this.updateCounts = null;
  }

  /**
   * Return the array of update counts.
   */
  public int[] getUpdateCounts() {
    return updateCounts;
  }

  private int[] updateCounts;
}
