home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / Java2 / src / java / sql / BatchUpdateException.java < prev    next >
Encoding:
Java Source  |  1999-05-28  |  4.1 KB  |  119 lines  |  [TEXT/CWIE]

  1. /*
  2.  * @(#)BatchUpdateException.java    1.7 98/05/08
  3.  *
  4.  * Copyright 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.sql;
  16.  
  17. /**
  18.  *  JDBC 2.0
  19.  *
  20.  *  <P>
  21.  *  An exception thrown when an error
  22.  *  occurs during a batch update operation.  In addition to the
  23.  *  information provided by {@link SQLException}, a 
  24.  *  <code>BatchUpdateException</code> provides the update
  25.  *  counts for all commands that were executed successfully during the
  26.  *  batch update, that is, all commands that were executed before the error 
  27.  *  occurred.  The order of elements in an array of update counts
  28.  *  corresponds to the order in which commands were added to the batch.
  29.  */
  30.  
  31. public class BatchUpdateException extends SQLException {
  32.  
  33.   /**
  34.    * Constructs a fully specified <code>BatchUpdateException</code>.
  35.    * @param reason a description of the error 
  36.    * @param SQLState an X/OPEN code identifying the error
  37.    * @param vendorCode an exception code for a particular
  38.    * database vendor
  39.    * @param updateCounts an array of <code>int</code>, with each element
  40.    * indicating the update count for a SQL command that executed 
  41.    * successfully before the exception was thrown
  42.    */
  43.   public BatchUpdateException( String reason, String SQLState, int vendorCode, 
  44.                    int[] updateCounts ) {
  45.     super(reason, SQLState, vendorCode);
  46.     this.updateCounts = updateCounts;
  47.   }
  48.  
  49.   /**
  50.    * Constructs a <code>BatchUpdateException</code> initialized with 
  51.    * the given arguments (<code>reason</code>,
  52.    * <code>SQLState</code>, and <code>updateCounts</code>) and 0 for the vendor
  53.    * code.
  54.    * @param reason a description of the exception 
  55.    * @param SQLState an X/OPEN code identifying the exception 
  56.    * @param updateCounts an array of <code>int</code>, with each element  
  57.    * indicating the update count for a SQL command that executed
  58.    * successfully before the exception was thrown  
  59.    */
  60.   public BatchUpdateException(String reason, String SQLState, 
  61.                   int[] updateCounts) {
  62.     super(reason, SQLState);
  63.     this.updateCounts = updateCounts;
  64.   }
  65.  
  66.   /**
  67.    * Constructs a <code>BatchUpdateException</code> initialized with
  68.    * <code>reason</code>, <code>updateCounts</code> and <code>null</code>
  69.    * for the SQLState and 0 for the vendorCode.
  70.    * @param reason a description of the exception 
  71.    * @param updateCounts an array of <code>int</code>, with each element
  72.    * indicating the update count for a SQL command that executed
  73.    * successfully before the exception was thrown
  74.    */
  75.   public  BatchUpdateException(String reason, int[] updateCounts) {
  76.     super(reason);
  77.     this.updateCounts = updateCounts;
  78.   }
  79.  
  80.   /**
  81.    * Constructs a <code>BatchUpdateException</code> initialized to 
  82.    * <code>null</code> for the reason and SQLState and 0 for the
  83.    * vendor code.
  84.    * @param updateCounts an array of <code>int</code>, with each element
  85.    * indicating the update count for a SQL command that executed
  86.    * successfully before the exception was thrown
  87.    */
  88.   public BatchUpdateException(int[] updateCounts) {
  89.     super();
  90.     this.updateCounts = updateCounts;
  91.   }
  92.  
  93.   /**
  94.    * Constructs a <code>BatchUpdateException</code> object 
  95.    * with the reason, SQLState, and update count initialized to
  96.    * <code>null</code> and the vendor code initialized to 0.
  97.    */
  98.   public BatchUpdateException() {
  99.     super();
  100.     this.updateCounts = null;
  101.   }
  102.  
  103.   /**
  104.    * Retrieves the update count for each update statement in the batch
  105.    * update that executed successfully before this exception occurred.
  106.    * @return an array of <code>int</code> containing the update counts
  107.    * for the updates that were executed successfully before this error
  108.    * occurred
  109.    */
  110.   public int[] getUpdateCounts() {
  111.     return updateCounts;
  112.   }
  113.  
  114.   /**
  115.    * @serial
  116.    */
  117.   private int[] updateCounts;
  118. }
  119.