jdk/src/share/classes/java/sql/BatchUpdateException.java
author chegar
Tue, 12 May 2009 16:32:34 +0100
changeset 3450 2f08a8bb9b83
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6801071: Remote sites can compromise user privacy and possibly hijack web sessions Reviewed-by: jccollet, hawtin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1998-2005 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.sql;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * The subclass of {@link SQLException} thrown when an error
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * occurs during a batch update operation.  In addition to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * information provided by {@link SQLException}, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * <code>BatchUpdateException</code> provides the update
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * counts for all commands that were executed successfully during the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * batch update, that is, all commands that were executed before the error
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * occurred.  The order of elements in an array of update counts
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * corresponds to the order in which commands were added to the batch.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * After a command in a batch update fails to execute properly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * and a <code>BatchUpdateException</code> is thrown, the driver
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * may or may not continue to process the remaining commands in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * the batch.  If the driver continues processing after a failure,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * the array returned by the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <code>BatchUpdateException.getUpdateCounts</code> will have
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * an element for every command in the batch rather than only
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * elements for the commands that executed successfully before
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * the error.  In the case where the driver continues processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * commands, the array element for any command
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * that failed is <code>Statement.EXECUTE_FAILED</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
public class BatchUpdateException extends SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
   * Constructs a <code>BatchUpdateException</code> object initialized with a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
   * <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
   * <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
   * The <code>cause</code> is not initialized, and may subsequently be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
   * initialized by a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
   * {@link Throwable#initCause(java.lang.Throwable)} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
   * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
   * @param reason a description of the error
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
   * @param SQLState an XOPEN or SQL:2003 code identifying the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
   * @param vendorCode an exception code used by a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
   * database vendor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
   * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
   * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
  public BatchUpdateException( String reason, String SQLState, int vendorCode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                               int[] updateCounts ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    super(reason, SQLState, vendorCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    this.updateCounts = updateCounts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
   * Constructs a <code>BatchUpdateException</code> object initialized with a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
   * <code>reason</code>, <code>SQLState</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
   * <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
   * The <code>cause</code> is not initialized, and may subsequently be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
   * initialized by a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
   * {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
   * is intialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
   * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
   * @param reason a description of the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
   * @param SQLState an XOPEN or SQL:2003 code identifying the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
   * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
   * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
  public BatchUpdateException(String reason, String SQLState,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                              int[] updateCounts) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    super(reason, SQLState);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    this.updateCounts = updateCounts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
   * Constructs a <code>BatchUpdateException</code> object initialized with a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
   * <code>reason</code> and <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
   * The <code>cause</code> is not initialized, and may subsequently be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
   * initialized by a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
   * {@link Throwable#initCause(java.lang.Throwable)} method.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
   * <code>SQLState</code> is initialized to <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
   * and the vender code is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
   * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
   * @param reason a description of the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
   * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
   * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
  public  BatchUpdateException(String reason, int[] updateCounts) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    super(reason);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    this.updateCounts = updateCounts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
   * Constructs a <code>BatchUpdateException</code> object initialized with a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
   * <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
   * initialized by a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
   * {@link Throwable#initCause(java.lang.Throwable)} method. The  <code>reason</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
   * and <code>SQLState</code> are initialized to null and the vendor code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
   * is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
   * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
   * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
   * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
  public BatchUpdateException(int[] updateCounts) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    this.updateCounts = updateCounts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
   * Constructs a <code>BatchUpdateException</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
   * The <code>reason</code>, <code>SQLState</code> and <code>updateCounts</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
   *  are initialized to <code>null</code> and the vendor code is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
   * The <code>cause</code> is not initialized, and may subsequently be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
   * initialized by a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
   * {@link Throwable#initCause(java.lang.Throwable)} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
   * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
  public BatchUpdateException() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    this.updateCounts = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * Constructs a <code>BatchUpdateException</code> object initialized with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     *  a given <code>cause</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * The <code>SQLState</code> and <code>updateCounts</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * are initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * to <code>null</code> and the vendor code is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * The <code>reason</code>  is initialized to <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * <code>cause==null</code> or to <code>cause.toString()</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *  <code>cause!=null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @param cause the underlying reason for this <code>SQLException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * (which is saved for later retrieval by the <code>getCause()</code> method);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * may be null indicating the cause is non-existent or unknown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    public BatchUpdateException(Throwable cause) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        super(cause);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        this.updateCounts = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * Constructs a <code>BatchUpdateException</code> object initialized with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * given <code>cause</code> and <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * The <code>SQLState</code> is initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * to <code>null</code> and the vendor code is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * The <code>reason</code>  is initialized to <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * <code>cause==null</code> or to <code>cause.toString()</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * <code>cause!=null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @param cause the underlying reason for this <code>SQLException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * the cause is non-existent or unknown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    public BatchUpdateException(int []updateCounts , Throwable cause) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        super(cause);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        this.updateCounts = updateCounts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * Constructs a <code>BatchUpdateException</code> object initialized with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * a given <code>reason</code>, <code>cause</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * and <code>updateCounts</code>. The <code>SQLState</code> is initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * to <code>null</code> and the vendor code is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * @param reason a description of the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     *indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * may be null indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * the cause is non-existent or unknown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    public BatchUpdateException(String reason, int []updateCounts, Throwable cause) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        super(reason,cause);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        this.updateCounts = updateCounts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * Constructs a <code>BatchUpdateException</code> object initialized with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * a given <code>reason</code>, <code>SQLState</code>,<code>cause</code>, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
   * <code>updateCounts</code>. The vendor code is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * @param reason a description of the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * @param SQLState an XOPEN or SQL:2003 code identifying the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * may be null indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * the cause is non-existent or unknown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    public BatchUpdateException(String reason, String SQLState,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                                int []updateCounts, Throwable cause) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        super(reason,SQLState,cause);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        this.updateCounts = updateCounts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * Constructs a <code>BatchUpdateException</code> object initialized with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * a given <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * <code>cause</code> and <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @param reason a description of the error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @param SQLState an XOPEN or SQL:2003 code identifying the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * @param vendorCode an exception code used by a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * database vendor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     *indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * may be null indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * the cause is non-existent or unknown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    public BatchUpdateException(String reason, String SQLState, int vendorCode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                                int []updateCounts,Throwable cause) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        super(reason,SQLState,vendorCode,cause);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        this.updateCounts = updateCounts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
   * Retrieves the update count for each update statement in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
   * update that executed successfully before this exception occurred.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
   * A driver that implements batch updates may or may not continue to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
   * process the remaining commands in a batch when one of the commands
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
   * fails to execute properly. If the driver continues processing commands,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
   * the array returned by this method will have as many elements as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
   * there are commands in the batch; otherwise, it will contain an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
   * update count for each command that executed successfully before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
   * the <code>BatchUpdateException</code> was thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
   *<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
   * The possible return values for this method were modified for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
   * the Java 2 SDK, Standard Edition, version 1.3.  This was done to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
   * accommodate the new option of continuing to process commands
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
   * in a batch update after a <code>BatchUpdateException</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
   * has been thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
   * @return an array of <code>int</code> containing the update counts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
   * for the updates that were executed successfully before this error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
   * occurred.  Or, if the driver continues to process commands after an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
   * error, one of the following for every command in the batch:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
   * <OL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
   * <LI>an update count
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
   *  <LI><code>Statement.SUCCESS_NO_INFO</code> to indicate that the command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
   *     executed successfully but the number of rows affected is unknown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
   *  <LI><code>Statement.EXECUTE_FAILED</code> to indicate that the command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
   *     failed to execute successfully
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
   * </OL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
   * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
  public int[] getUpdateCounts() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    return updateCounts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
   * The array that describes the outcome of a batch execution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
   * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
  private int[] updateCounts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
  private static final long serialVersionUID = 5977529877145521757L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
}