jdk/src/share/classes/java/sql/BatchUpdateException.java
author lancea
Thu, 02 Jun 2011 12:02:14 -0400
changeset 9777 3f97b6a96ac5
parent 9684 90ce88ea5ade
child 15278 e081d3f73b75
permissions -rw-r--r--
7049107: Cannot call initCause() on BatchUpdateException Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
     2
 * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
2
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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
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
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
    28
import java.util.Arrays;
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
    29
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * The subclass of {@link SQLException} thrown when an error
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * occurs during a batch update operation.  In addition to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * information provided by {@link SQLException}, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <code>BatchUpdateException</code> provides the update
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * counts for all commands that were executed successfully during the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * batch update, that is, all commands that were executed before the error
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * occurred.  The order of elements in an array of update counts
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * corresponds to the order in which commands were added to the batch.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * After a command in a batch update fails to execute properly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * and a <code>BatchUpdateException</code> is thrown, the driver
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * may or may not continue to process the remaining commands in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * the batch.  If the driver continues processing after a failure,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * the array returned by the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <code>BatchUpdateException.getUpdateCounts</code> will have
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * an element for every command in the batch rather than only
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * elements for the commands that executed successfully before
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * the error.  In the case where the driver continues processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * commands, the array element for any command
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * that failed is <code>Statement.EXECUTE_FAILED</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
public class BatchUpdateException extends SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
   * Constructs a <code>BatchUpdateException</code> object initialized with a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
   * <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
   * <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
   * The <code>cause</code> is not initialized, and may subsequently be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
   * initialized by a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
   * {@link Throwable#initCause(java.lang.Throwable)} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
   * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
   * @param reason a description of the error
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
   * @param SQLState an XOPEN or SQL:2003 code identifying the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
   * @param vendorCode an exception code used by a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
   * database vendor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
   * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
   * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
  public BatchUpdateException( String reason, String SQLState, int vendorCode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                               int[] updateCounts ) {
9777
3f97b6a96ac5 7049107: Cannot call initCause() on BatchUpdateException
lancea
parents: 9684
diff changeset
    82
      super(reason, SQLState, vendorCode);
3f97b6a96ac5 7049107: Cannot call initCause() on BatchUpdateException
lancea
parents: 9684
diff changeset
    83
      this.updateCounts  = (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
   * Constructs a <code>BatchUpdateException</code> object initialized with a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
   * <code>reason</code>, <code>SQLState</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
   * <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
   * The <code>cause</code> is not initialized, and may subsequently be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
   * initialized by a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
   * {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
9684
90ce88ea5ade 7043443: address missed reason initialization in BatchUpdateException
lancea
parents: 9529
diff changeset
    93
   * is initialized to 0.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
   * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
   * @param reason a description of the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
   * @param SQLState an XOPEN or SQL:2003 code identifying the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
   * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
   * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
  public BatchUpdateException(String reason, String SQLState,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                              int[] updateCounts) {
9777
3f97b6a96ac5 7049107: Cannot call initCause() on BatchUpdateException
lancea
parents: 9684
diff changeset
   110
      this(reason, SQLState, 0, updateCounts);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
   * Constructs a <code>BatchUpdateException</code> object initialized with a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
   * <code>reason</code> and <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
   * The <code>cause</code> is not initialized, and may subsequently be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
   * initialized by a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
   * {@link Throwable#initCause(java.lang.Throwable)} method.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
   * <code>SQLState</code> is initialized to <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
   * and the vender code is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
   * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
   * @param reason a description of the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
   * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
   * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
  public  BatchUpdateException(String reason, int[] updateCounts) {
9777
3f97b6a96ac5 7049107: Cannot call initCause() on BatchUpdateException
lancea
parents: 9684
diff changeset
   136
      this(reason, null, 0, updateCounts);
2
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) {
9777
3f97b6a96ac5 7049107: Cannot call initCause() on BatchUpdateException
lancea
parents: 9684
diff changeset
   159
      this(null, null, 0, updateCounts);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
   * Constructs a <code>BatchUpdateException</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
   * The <code>reason</code>, <code>SQLState</code> and <code>updateCounts</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
   *  are initialized to <code>null</code> and the vendor code is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
   * The <code>cause</code> is not initialized, and may subsequently be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
   * initialized by a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
   * {@link Throwable#initCause(java.lang.Throwable)} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
   * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
  public BatchUpdateException() {
9777
3f97b6a96ac5 7049107: Cannot call initCause() on BatchUpdateException
lancea
parents: 9684
diff changeset
   174
        this(null, null, 0, null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * Constructs a <code>BatchUpdateException</code> object initialized with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     *  a given <code>cause</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * The <code>SQLState</code> and <code>updateCounts</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * are initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * to <code>null</code> and the vendor code is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * The <code>reason</code>  is initialized to <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * <code>cause==null</code> or to <code>cause.toString()</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *  <code>cause!=null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @param cause the underlying reason for this <code>SQLException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * (which is saved for later retrieval by the <code>getCause()</code> method);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * may be null indicating the cause is non-existent or unknown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    public BatchUpdateException(Throwable cause) {
9684
90ce88ea5ade 7043443: address missed reason initialization in BatchUpdateException
lancea
parents: 9529
diff changeset
   192
        this((cause == null ? null : cause.toString()), null, 0, null, cause);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * Constructs a <code>BatchUpdateException</code> object initialized with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * given <code>cause</code> and <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * The <code>SQLState</code> is initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * to <code>null</code> and the vendor code is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * The <code>reason</code>  is initialized to <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * <code>cause==null</code> or to <code>cause.toString()</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * <code>cause!=null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @param cause the underlying reason for this <code>SQLException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * the cause is non-existent or unknown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    public BatchUpdateException(int []updateCounts , Throwable cause) {
9684
90ce88ea5ade 7043443: address missed reason initialization in BatchUpdateException
lancea
parents: 9529
diff changeset
   218
        this((cause == null ? null : cause.toString()), null, 0, updateCounts, cause);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * Constructs a <code>BatchUpdateException</code> object initialized with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * a given <code>reason</code>, <code>cause</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * and <code>updateCounts</code>. The <code>SQLState</code> is initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * to <code>null</code> and the vendor code is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @param reason a description of the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     *indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * @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
   237
     * may be null indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * the cause is non-existent or unknown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    public BatchUpdateException(String reason, int []updateCounts, Throwable cause) {
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   242
        this(reason, null, 0, updateCounts, cause);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * Constructs a <code>BatchUpdateException</code> object initialized with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * a given <code>reason</code>, <code>SQLState</code>,<code>cause</code>, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
   * <code>updateCounts</code>. The vendor code is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * @param reason a description of the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * @param SQLState an XOPEN or SQL:2003 code identifying the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * @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
   261
     * may be null indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * the cause is non-existent or unknown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    public BatchUpdateException(String reason, String SQLState,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                                int []updateCounts, Throwable cause) {
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   267
        this(reason, SQLState, 0, updateCounts, cause);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * Constructs a <code>BatchUpdateException</code> object initialized with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * a given <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * <code>cause</code> and <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * @param reason a description of the error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * @param SQLState an XOPEN or SQL:2003 code identifying the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * @param vendorCode an exception code used by a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * database vendor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     *indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * @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
   288
     * may be null indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * the cause is non-existent or unknown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    public BatchUpdateException(String reason, String SQLState, int vendorCode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                                int []updateCounts,Throwable cause) {
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   294
        super(reason, SQLState, vendorCode, cause);
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   295
        this.updateCounts  = (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
   * Retrieves the update count for each update statement in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
   * update that executed successfully before this exception occurred.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
   * A driver that implements batch updates may or may not continue to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
   * process the remaining commands in a batch when one of the commands
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
   * fails to execute properly. If the driver continues processing commands,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
   * the array returned by this method will have as many elements as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
   * there are commands in the batch; otherwise, it will contain an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
   * update count for each command that executed successfully before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
   * the <code>BatchUpdateException</code> was thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
   *<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
   * The possible return values for this method were modified for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
   * the Java 2 SDK, Standard Edition, version 1.3.  This was done to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
   * accommodate the new option of continuing to process commands
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
   * in a batch update after a <code>BatchUpdateException</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
   * has been thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
   * @return an array of <code>int</code> containing the update counts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
   * for the updates that were executed successfully before this error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
   * occurred.  Or, if the driver continues to process commands after an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
   * error, one of the following for every command in the batch:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
   * <OL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
   * <LI>an update count
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
   *  <LI><code>Statement.SUCCESS_NO_INFO</code> to indicate that the command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
   *     executed successfully but the number of rows affected is unknown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
   *  <LI><code>Statement.EXECUTE_FAILED</code> to indicate that the command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
   *     failed to execute successfully
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
   * </OL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
   * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
  public int[] getUpdateCounts() {
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   329
      return (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
   * The array that describes the outcome of a batch execution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
   * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
   */
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   337
  private final int[] updateCounts;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
  private static final long serialVersionUID = 5977529877145521757L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
}