jdk/src/share/classes/java/sql/BatchUpdateException.java
author lancea
Tue, 10 May 2011 14:41:18 -0400
changeset 9684 90ce88ea5ade
parent 9529 56e620fd7c58
child 9777 3f97b6a96ac5
permissions -rw-r--r--
7043443: address missed reason initialization in BatchUpdateException Reviewed-by: alanb
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 ) {
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
    82
      this(reason, SQLState, vendorCode, updateCounts, null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
   * Constructs a <code>BatchUpdateException</code> object initialized with a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
   * <code>reason</code>, <code>SQLState</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
   * <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
   * The <code>cause</code> is not initialized, and may subsequently be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
   * initialized by a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
   * {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
9684
90ce88ea5ade 7043443: address missed reason initialization in BatchUpdateException
lancea
parents: 9529
diff changeset
    92
   * is initialized to 0.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
   * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
   * @param reason a description of the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
   * @param SQLState an XOPEN or SQL:2003 code identifying the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
   * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
   * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
  public BatchUpdateException(String reason, String SQLState,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                              int[] updateCounts) {
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   109
      this(reason, SQLState, 0, updateCounts, null);
2
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) {
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   135
      this(reason, null, 0, updateCounts, null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
   * Constructs a <code>BatchUpdateException</code> object initialized with a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
   * <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
   * initialized by a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
   * {@link Throwable#initCause(java.lang.Throwable)} method. The  <code>reason</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
   * and <code>SQLState</code> are initialized to null and the vendor code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
   * is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
   * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
   * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
   * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
  public BatchUpdateException(int[] updateCounts) {
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   158
      this(null, null, 0, updateCounts, null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
   * Constructs a <code>BatchUpdateException</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
   * The <code>reason</code>, <code>SQLState</code> and <code>updateCounts</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
   *  are initialized to <code>null</code> and the vendor code is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
   * The <code>cause</code> is not initialized, and may subsequently be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
   * initialized by a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
   * {@link Throwable#initCause(java.lang.Throwable)} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
   * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
  public BatchUpdateException() {
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   173
        this(null, null, 0, null, null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * Constructs a <code>BatchUpdateException</code> object initialized with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     *  a given <code>cause</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * The <code>SQLState</code> and <code>updateCounts</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * are initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * to <code>null</code> and the vendor code is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * The <code>reason</code>  is initialized to <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * <code>cause==null</code> or to <code>cause.toString()</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *  <code>cause!=null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @param cause the underlying reason for this <code>SQLException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * (which is saved for later retrieval by the <code>getCause()</code> method);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * may be null indicating the cause is non-existent or unknown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public BatchUpdateException(Throwable cause) {
9684
90ce88ea5ade 7043443: address missed reason initialization in BatchUpdateException
lancea
parents: 9529
diff changeset
   191
        this((cause == null ? null : cause.toString()), null, 0, null, cause);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * Constructs a <code>BatchUpdateException</code> object initialized with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * given <code>cause</code> and <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * The <code>SQLState</code> is initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * to <code>null</code> and the vendor code is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * The <code>reason</code>  is initialized to <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * <code>cause==null</code> or to <code>cause.toString()</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * <code>cause!=null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * @param cause the underlying reason for this <code>SQLException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * the cause is non-existent or unknown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    public BatchUpdateException(int []updateCounts , Throwable cause) {
9684
90ce88ea5ade 7043443: address missed reason initialization in BatchUpdateException
lancea
parents: 9529
diff changeset
   217
        this((cause == null ? null : cause.toString()), null, 0, updateCounts, cause);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * Constructs a <code>BatchUpdateException</code> object initialized with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * a given <code>reason</code>, <code>cause</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * and <code>updateCounts</code>. The <code>SQLState</code> is initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * to <code>null</code> and the vendor code is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * @param reason a description of the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * @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
   236
     * may be null indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * the cause is non-existent or unknown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    public BatchUpdateException(String reason, int []updateCounts, Throwable cause) {
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   241
        this(reason, null, 0, updateCounts, cause);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * Constructs a <code>BatchUpdateException</code> object initialized with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * a given <code>reason</code>, <code>SQLState</code>,<code>cause</code>, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
   * <code>updateCounts</code>. The vendor code is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * @param reason a description of the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * @param SQLState an XOPEN or SQL:2003 code identifying the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * @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
   260
     * may be null indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * the cause is non-existent or unknown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    public BatchUpdateException(String reason, String SQLState,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                                int []updateCounts, Throwable cause) {
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   266
        this(reason, SQLState, 0, updateCounts, cause);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * Constructs a <code>BatchUpdateException</code> object initialized with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * a given <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * <code>cause</code> and <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * @param reason a description of the error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * @param SQLState an XOPEN or SQL:2003 code identifying the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * @param vendorCode an exception code used by a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * database vendor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     *indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * @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
   287
     * may be null indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * the cause is non-existent or unknown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    public BatchUpdateException(String reason, String SQLState, int vendorCode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                                int []updateCounts,Throwable cause) {
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   293
        super(reason, SQLState, vendorCode, cause);
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   294
        this.updateCounts  = (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
   * Retrieves the update count for each update statement in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
   * update that executed successfully before this exception occurred.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
   * A driver that implements batch updates may or may not continue to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
   * process the remaining commands in a batch when one of the commands
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
   * fails to execute properly. If the driver continues processing commands,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
   * the array returned by this method will have as many elements as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
   * there are commands in the batch; otherwise, it will contain an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
   * update count for each command that executed successfully before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
   * the <code>BatchUpdateException</code> was thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
   *<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
   * The possible return values for this method were modified for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
   * the Java 2 SDK, Standard Edition, version 1.3.  This was done to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
   * accommodate the new option of continuing to process commands
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
   * in a batch update after a <code>BatchUpdateException</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
   * has been thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
   * @return an array of <code>int</code> containing the update counts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
   * for the updates that were executed successfully before this error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
   * occurred.  Or, if the driver continues to process commands after an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
   * error, one of the following for every command in the batch:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
   * <OL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
   * <LI>an update count
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
   *  <LI><code>Statement.SUCCESS_NO_INFO</code> to indicate that the command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
   *     executed successfully but the number of rows affected is unknown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
   *  <LI><code>Statement.EXECUTE_FAILED</code> to indicate that the command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
   *     failed to execute successfully
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
   * </OL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
   * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
  public int[] getUpdateCounts() {
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   328
      return (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
   * The array that describes the outcome of a batch execution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
   * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
   */
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   336
  private final int[] updateCounts;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
  private static final long serialVersionUID = 5977529877145521757L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
}