jdk/src/java.sql/share/classes/java/sql/BatchUpdateException.java
author chegar
Mon, 18 Aug 2014 10:59:36 +0100
changeset 25991 e48157b42439
parent 25976 jdk/src/share/classes/java/sql/BatchUpdateException.java@4de01a56e3ee
parent 25859 jdk/src/share/classes/java/sql/BatchUpdateException.java@3317bb8137f4
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
25976
4de01a56e3ee 8054555: javadoc cleanup for java.sql and javax.sql
lancea
parents: 23590
diff changeset
     2
 * Copyright (c) 1998, 2014, 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
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    28
import java.io.IOException;
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    29
import java.io.InvalidObjectException;
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    30
import java.io.ObjectInputStream;
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    31
import java.io.ObjectOutputStream;
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
    32
import java.util.Arrays;
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
    33
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * The subclass of {@link SQLException} thrown when an error
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * occurs during a batch update operation.  In addition to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * information provided by {@link SQLException}, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <code>BatchUpdateException</code> provides the update
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * counts for all commands that were executed successfully during the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * batch update, that is, all commands that were executed before the error
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * occurred.  The order of elements in an array of update counts
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * corresponds to the order in which commands were added to the batch.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * After a command in a batch update fails to execute properly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * and a <code>BatchUpdateException</code> is thrown, the driver
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * may or may not continue to process the remaining commands in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * the batch.  If the driver continues processing after a failure,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * the array returned by the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <code>BatchUpdateException.getUpdateCounts</code> will have
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * an element for every command in the batch rather than only
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * elements for the commands that executed successfully before
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * the error.  In the case where the driver continues processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * commands, the array element for any command
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * that failed is <code>Statement.EXECUTE_FAILED</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <P>
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    56
 * A JDBC driver implementation should use
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    57
 * the constructor {@code BatchUpdateException(String reason, String SQLState,
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    58
 * int vendorCode, long []updateCounts,Throwable cause) } instead of
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    59
 * constructors that take {@code int[]} for the update counts to avoid the
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    60
 * possibility of overflow.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    61
 * <p>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    62
 * If {@code Statement.executeLargeBatch} method is invoked it is recommended that
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    63
 * {@code getLargeUpdateCounts} be called instead of {@code getUpdateCounts}
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    64
 * in order to avoid a possible overflow of the integer update count.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
public class BatchUpdateException extends SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
   * Constructs a <code>BatchUpdateException</code> object initialized with a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
   * <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
   * <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
   * The <code>cause</code> is not initialized, and may subsequently be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
   * initialized by a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
   * {@link Throwable#initCause(java.lang.Throwable)} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
   * <p>
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    78
   * <strong>Note:</strong> There is no validation of {@code updateCounts} for
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    79
   * overflow and because of this it is recommended that you use the constructor
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    80
   * {@code BatchUpdateException(String reason, String SQLState,
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    81
   * int vendorCode, long []updateCounts,Throwable cause) }.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    82
   * </p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
   * @param reason a description of the error
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
   * @param SQLState an XOPEN or SQL:2003 code identifying the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
   * @param vendorCode an exception code used by a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
   * database vendor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
   * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
   * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
   * @since 1.2
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    96
   * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
    97
   * java.lang.Throwable)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
  public BatchUpdateException( String reason, String SQLState, int vendorCode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                               int[] updateCounts ) {
9777
3f97b6a96ac5 7049107: Cannot call initCause() on BatchUpdateException
lancea
parents: 9684
diff changeset
   101
      super(reason, SQLState, vendorCode);
3f97b6a96ac5 7049107: Cannot call initCause() on BatchUpdateException
lancea
parents: 9684
diff changeset
   102
      this.updateCounts  = (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   103
      this.longUpdateCounts = (updateCounts == null) ? null : copyUpdateCount(updateCounts);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
   * Constructs a <code>BatchUpdateException</code> object initialized with a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
   * <code>reason</code>, <code>SQLState</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
   * <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
   * The <code>cause</code> is not initialized, and may subsequently be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
   * initialized by a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
   * {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
9684
90ce88ea5ade 7043443: address missed reason initialization in BatchUpdateException
lancea
parents: 9529
diff changeset
   113
   * is initialized to 0.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
   * <p>
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   115
   * <strong>Note:</strong> There is no validation of {@code updateCounts} for
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   116
   * overflow and because of this it is recommended that you use the constructor
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   117
   * {@code BatchUpdateException(String reason, String SQLState,
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   118
   * int vendorCode, long []updateCounts,Throwable cause) }.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   119
   * </p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
   * @param reason a description of the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
   * @param SQLState an XOPEN or SQL:2003 code identifying the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
   * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
   * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
   * @since 1.2
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   131
   * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   132
   * java.lang.Throwable)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
  public BatchUpdateException(String reason, String SQLState,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                              int[] updateCounts) {
9777
3f97b6a96ac5 7049107: Cannot call initCause() on BatchUpdateException
lancea
parents: 9684
diff changeset
   136
      this(reason, SQLState, 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>reason</code> and <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
   * The <code>cause</code> is not initialized, and may subsequently be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
   * initialized by a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
   * {@link Throwable#initCause(java.lang.Throwable)} method.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
   * <code>SQLState</code> is initialized to <code>null</code>
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 15284
diff changeset
   146
   * and the vendor code is initialized to 0.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
   * <p>
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   148
   * <strong>Note:</strong> There is no validation of {@code updateCounts} for
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   149
   * overflow and because of this it is recommended that you use the constructor
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   150
   * {@code BatchUpdateException(String reason, String SQLState,
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   151
   * int vendorCode, long []updateCounts,Throwable cause) }.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   152
   * </p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
   * @param reason a description of the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
   * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
   * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
   * @since 1.2
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   163
   * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   164
   * java.lang.Throwable)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
  public  BatchUpdateException(String reason, int[] updateCounts) {
9777
3f97b6a96ac5 7049107: Cannot call initCause() on BatchUpdateException
lancea
parents: 9684
diff changeset
   167
      this(reason, null, 0, updateCounts);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
   * Constructs a <code>BatchUpdateException</code> object initialized with a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
   * <code>updateCounts</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
   * initialized by a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
   * {@link Throwable#initCause(java.lang.Throwable)} method. The  <code>reason</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
   * and <code>SQLState</code> are initialized to null and the vendor code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
   * is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
   * <p>
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   178
   * <strong>Note:</strong> There is no validation of {@code updateCounts} for
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   179
   * overflow and because of this it is recommended that you use the constructor
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   180
   * {@code BatchUpdateException(String reason, String SQLState,
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   181
   * int vendorCode, long []updateCounts,Throwable cause) }.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   182
   * </p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
   * @param updateCounts an array of <code>int</code>, with each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
   * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
   * failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
   * @since 1.2
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   192
   * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   193
   * java.lang.Throwable)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
  public BatchUpdateException(int[] updateCounts) {
9777
3f97b6a96ac5 7049107: Cannot call initCause() on BatchUpdateException
lancea
parents: 9684
diff changeset
   196
      this(null, null, 0, updateCounts);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
   * Constructs a <code>BatchUpdateException</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
   * The <code>reason</code>, <code>SQLState</code> and <code>updateCounts</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
   *  are initialized to <code>null</code> and the vendor code is initialized to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
   * The <code>cause</code> is not initialized, and may subsequently be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
   * initialized by a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
   * {@link Throwable#initCause(java.lang.Throwable)} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
   * @since 1.2
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   208
   * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   209
   * java.lang.Throwable)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
  public BatchUpdateException() {
9777
3f97b6a96ac5 7049107: Cannot call initCause() on BatchUpdateException
lancea
parents: 9684
diff changeset
   212
        this(null, null, 0, null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   215
  /**
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   216
   * Constructs a <code>BatchUpdateException</code> object initialized with
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   217
   *  a given <code>cause</code>.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   218
   * The <code>SQLState</code> and <code>updateCounts</code>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   219
   * are initialized
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   220
   * to <code>null</code> and the vendor code is initialized to 0.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   221
   * The <code>reason</code>  is initialized to <code>null</code> if
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   222
   * <code>cause==null</code> or to <code>cause.toString()</code> if
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   223
   *  <code>cause!=null</code>.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   224
   * @param cause the underlying reason for this <code>SQLException</code>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   225
   * (which is saved for later retrieval by the <code>getCause()</code> method);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   226
   * may be null indicating the cause is non-existent or unknown.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   227
   * @since 1.6
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   228
   * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   229
   * java.lang.Throwable)
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   230
   */
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   231
  public BatchUpdateException(Throwable cause) {
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   232
      this((cause == null ? null : cause.toString()), null, 0, (int[])null, cause);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   233
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   235
  /**
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   236
   * Constructs a <code>BatchUpdateException</code> object initialized with a
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   237
   * given <code>cause</code> and <code>updateCounts</code>.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   238
   * The <code>SQLState</code> is initialized
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   239
   * to <code>null</code> and the vendor code is initialized to 0.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   240
   * The <code>reason</code>  is initialized to <code>null</code> if
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   241
   * <code>cause==null</code> or to <code>cause.toString()</code> if
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   242
   * <code>cause!=null</code>.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   243
   * <p>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   244
   * <strong>Note:</strong> There is no validation of {@code updateCounts} for
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   245
   * overflow and because of this it is recommended that you use the constructor
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   246
   * {@code BatchUpdateException(String reason, String SQLState,
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   247
   * int vendorCode, long []updateCounts,Throwable cause) }.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   248
   * </p>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   249
   * @param updateCounts an array of <code>int</code>, with each element
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   250
   * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   251
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   252
   * the batch for JDBC drivers that continue processing
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   253
   * after a command failure; an update count or
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   254
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   255
   * prior to the failure for JDBC drivers that stop processing after a command
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   256
   * failure
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   257
   * @param cause the underlying reason for this <code>SQLException</code>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   258
   * (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   259
   * the cause is non-existent or unknown.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   260
   * @since 1.6
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   261
   * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   262
   * java.lang.Throwable)
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   263
   */
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   264
  public BatchUpdateException(int []updateCounts , Throwable cause) {
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   265
      this((cause == null ? null : cause.toString()), null, 0, updateCounts, cause);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   266
  }
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   267
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   268
  /**
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   269
   * Constructs a <code>BatchUpdateException</code> object initialized with
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   270
   * a given <code>reason</code>, <code>cause</code>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   271
   * and <code>updateCounts</code>. The <code>SQLState</code> is initialized
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   272
   * to <code>null</code> and the vendor code is initialized to 0.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   273
   * <p>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   274
   * <strong>Note:</strong> There is no validation of {@code updateCounts} for
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   275
   * overflow and because of this it is recommended that you use the constructor
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   276
   * {@code BatchUpdateException(String reason, String SQLState,
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   277
   * int vendorCode, long []updateCounts,Throwable cause) }.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   278
   * </p>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   279
   * @param reason a description of the exception
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   280
   * @param updateCounts an array of <code>int</code>, with each element
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   281
   *indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
   * failure
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   288
   * @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   289
   * may be null indicating
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   290
   * the cause is non-existent or unknown.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   291
   * @since 1.6
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   292
   * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   293
   * java.lang.Throwable)
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   294
   */
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   295
  public BatchUpdateException(String reason, int []updateCounts, Throwable cause) {
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   296
      this(reason, null, 0, updateCounts, cause);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   297
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   299
  /**
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   300
   * Constructs a <code>BatchUpdateException</code> object initialized with
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   301
   * a given <code>reason</code>, <code>SQLState</code>,<code>cause</code>, and
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   302
   * <code>updateCounts</code>. The vendor code is initialized to 0.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   303
   *
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   304
   * @param reason a description of the exception
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   305
   * @param SQLState an XOPEN or SQL:2003 code identifying the exception
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   306
   * @param updateCounts an array of <code>int</code>, with each element
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   307
   * indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
   * failure
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   314
   * <p>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   315
   * <strong>Note:</strong> There is no validation of {@code updateCounts} for
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   316
   * overflow and because of this it is recommended that you use the constructor
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   317
   * {@code BatchUpdateException(String reason, String SQLState,
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   318
   * int vendorCode, long []updateCounts,Throwable cause) }.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   319
   * </p>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   320
   * @param cause the underlying reason for this <code>SQLException</code>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   321
   * (which is saved for later retrieval by the <code>getCause()</code> method);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   322
   * may be null indicating
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   323
   * the cause is non-existent or unknown.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   324
   * @since 1.6
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   325
   * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   326
   * java.lang.Throwable)
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   327
   */
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   328
  public BatchUpdateException(String reason, String SQLState,
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   329
          int []updateCounts, Throwable cause) {
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   330
      this(reason, SQLState, 0, updateCounts, cause);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   331
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   333
  /**
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   334
   * Constructs a <code>BatchUpdateException</code> object initialized with
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   335
   * a given <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   336
   * <code>cause</code> and <code>updateCounts</code>.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   337
   *
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   338
   * @param reason a description of the error
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   339
   * @param SQLState an XOPEN or SQL:2003 code identifying the exception
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   340
   * @param vendorCode an exception code used by a particular
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   341
   * database vendor
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   342
   * @param updateCounts an array of <code>int</code>, with each element
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   343
   *indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
   * the batch for JDBC drivers that continue processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
   * after a command failure; an update count or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
   * prior to the failure for JDBC drivers that stop processing after a command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
   * failure
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   350
   * <p>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   351
   * <strong>Note:</strong> There is no validation of {@code updateCounts} for
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   352
   * overflow and because of this it is recommended that you use the constructor
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   353
   * {@code BatchUpdateException(String reason, String SQLState,
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   354
   * int vendorCode, long []updateCounts,Throwable cause) }.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   355
   * </p>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   356
   * @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   357
   * may be null indicating
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   358
   * the cause is non-existent or unknown.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   359
   * @since 1.6
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   360
   * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   361
   * java.lang.Throwable)
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   362
   */
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   363
  public BatchUpdateException(String reason, String SQLState, int vendorCode,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                                int []updateCounts,Throwable cause) {
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   365
        super(reason, SQLState, vendorCode, cause);
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   366
        this.updateCounts  = (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   367
        this.longUpdateCounts = (updateCounts == null) ? null : copyUpdateCount(updateCounts);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   368
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
   * Retrieves the update count for each update statement in the batch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
   * update that executed successfully before this exception occurred.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
   * A driver that implements batch updates may or may not continue to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
   * process the remaining commands in a batch when one of the commands
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
   * fails to execute properly. If the driver continues processing commands,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
   * the array returned by this method will have as many elements as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
   * there are commands in the batch; otherwise, it will contain an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
   * update count for each command that executed successfully before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
   * the <code>BatchUpdateException</code> was thrown.
23590
ffd8b0b70511 8038493: Tidy warnings cleanup for java.sql
yan
parents: 21278
diff changeset
   380
   * <P>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
   * The possible return values for this method were modified for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
   * the Java 2 SDK, Standard Edition, version 1.3.  This was done to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
   * accommodate the new option of continuing to process commands
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
   * in a batch update after a <code>BatchUpdateException</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
   * has been thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
   * @return an array of <code>int</code> containing the update counts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
   * for the updates that were executed successfully before this error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
   * occurred.  Or, if the driver continues to process commands after an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
   * error, one of the following for every command in the batch:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
   * <OL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
   * <LI>an update count
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
   *  <LI><code>Statement.SUCCESS_NO_INFO</code> to indicate that the command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
   *     executed successfully but the number of rows affected is unknown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
   *  <LI><code>Statement.EXECUTE_FAILED</code> to indicate that the command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
   *     failed to execute successfully
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
   * </OL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
   * @since 1.3
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   399
   * @see #getLargeUpdateCounts()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
  public int[] getUpdateCounts() {
9529
56e620fd7c58 7038565: address Findbugs issue in BatchUpdateException
lancea
parents: 5506
diff changeset
   402
      return (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
  /**
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   406
   * Constructs a <code>BatchUpdateException</code> object initialized with
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   407
   * a given <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   408
   * <code>cause</code> and <code>updateCounts</code>.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   409
   * <p>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   410
   * This constructor should be used when the returned update count may exceed
15284
aa4ba8514e3d 8006642: Fix javadoc warnings due to Integer.MAX_VALUE
lancea
parents: 15278
diff changeset
   411
   * {@link Integer#MAX_VALUE}.
23590
ffd8b0b70511 8038493: Tidy warnings cleanup for java.sql
yan
parents: 21278
diff changeset
   412
   *
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   413
   * @param reason a description of the error
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   414
   * @param SQLState an XOPEN or SQL:2003 code identifying the exception
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   415
   * @param vendorCode an exception code used by a particular
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   416
   * database vendor
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   417
   * @param updateCounts an array of <code>long</code>, with each element
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   418
   *indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   419
   * <code>Statement.EXECUTE_FAILED</code> for each SQL command in
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   420
   * the batch for JDBC drivers that continue processing
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   421
   * after a command failure; an update count or
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   422
   * <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   423
   * prior to the failure for JDBC drivers that stop processing after a command
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   424
   * failure
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   425
   * @param cause the underlying reason for this <code>SQLException</code>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   426
   * (which is saved for later retrieval by the <code>getCause()</code> method);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   427
   * may be null indicating the cause is non-existent or unknown.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   428
   * @since 1.8
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   429
   */
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   430
  public BatchUpdateException(String reason, String SQLState, int vendorCode,
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   431
          long []updateCounts,Throwable cause) {
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   432
      super(reason, SQLState, vendorCode, cause);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   433
      this.longUpdateCounts  = (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   434
      this.updateCounts = (longUpdateCounts == null) ? null : copyUpdateCount(longUpdateCounts);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   435
  }
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   436
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   437
  /**
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   438
   * Retrieves the update count for each update statement in the batch
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   439
   * update that executed successfully before this exception occurred.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   440
   * A driver that implements batch updates may or may not continue to
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   441
   * process the remaining commands in a batch when one of the commands
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   442
   * fails to execute properly. If the driver continues processing commands,
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   443
   * the array returned by this method will have as many elements as
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   444
   * there are commands in the batch; otherwise, it will contain an
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   445
   * update count for each command that executed successfully before
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   446
   * the <code>BatchUpdateException</code> was thrown.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   447
   * <p>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   448
   * This method should be used when {@code Statement.executeLargeBatch} is
15284
aa4ba8514e3d 8006642: Fix javadoc warnings due to Integer.MAX_VALUE
lancea
parents: 15278
diff changeset
   449
   * invoked and the returned update count may exceed {@link Integer#MAX_VALUE}.
23590
ffd8b0b70511 8038493: Tidy warnings cleanup for java.sql
yan
parents: 21278
diff changeset
   450
   *
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   451
   * @return an array of <code>long</code> containing the update counts
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   452
   * for the updates that were executed successfully before this error
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   453
   * occurred.  Or, if the driver continues to process commands after an
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   454
   * error, one of the following for every command in the batch:
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   455
   * <OL>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   456
   * <LI>an update count
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   457
   *  <LI><code>Statement.SUCCESS_NO_INFO</code> to indicate that the command
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   458
   *     executed successfully but the number of rows affected is unknown
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   459
   *  <LI><code>Statement.EXECUTE_FAILED</code> to indicate that the command
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   460
   *     failed to execute successfully
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   461
   * </OL>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   462
   * @since 1.8
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   463
   */
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   464
  public long[] getLargeUpdateCounts() {
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   465
      return (longUpdateCounts == null) ? null :
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   466
              Arrays.copyOf(longUpdateCounts, longUpdateCounts.length);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   467
  }
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   468
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   469
  /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
   * The array that describes the outcome of a batch execution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
   * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
   */
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   474
  private  int[] updateCounts;
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   475
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   476
  /*
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   477
   * Starting with Java SE 8, JDBC has added support for returning an update
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   478
   * count > Integer.MAX_VALUE.  Because of this the following changes were made
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   479
   * to BatchUpdateException:
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   480
   * <ul>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   481
   * <li>Add field longUpdateCounts</li>
25976
4de01a56e3ee 8054555: javadoc cleanup for java.sql and javax.sql
lancea
parents: 23590
diff changeset
   482
   * <li>Add Constructor which takes long[] for update counts</li>
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   483
   * <li>Add getLargeUpdateCounts method</li>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   484
   * </ul>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   485
   * When any of the constructors are called, the int[] and long[] updateCount
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   486
   * fields are populated by copying the one array to each other.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   487
   *
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   488
   * As the JDBC driver passes in the updateCounts, there has always been the
25976
4de01a56e3ee 8054555: javadoc cleanup for java.sql and javax.sql
lancea
parents: 23590
diff changeset
   489
   * possibility for overflow and BatchUpdateException does not need to account
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   490
   * for that, it simply copies the arrays.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   491
   *
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   492
   * JDBC drivers should always use the constructor that specifies long[] and
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   493
   * JDBC application developers should call getLargeUpdateCounts.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   494
   */
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   495
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   496
  /**
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   497
   * The array that describes the outcome of a batch execution.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   498
   * @serial
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   499
   * @since 1.8
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   500
   */
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   501
  private  long[] longUpdateCounts;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
  private static final long serialVersionUID = 5977529877145521757L;
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   504
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   505
  /*
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   506
   * Utility method to copy int[] updateCount to long[] updateCount
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   507
   */
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   508
  private static long[] copyUpdateCount(int[] uc) {
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   509
      long[] copy = new long[uc.length];
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   510
      for(int i= 0; i< uc.length; i++) {
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   511
          copy[i] = uc[i];
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   512
      }
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   513
      return copy;
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   514
  }
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   515
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   516
  /*
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   517
   * Utility method to copy long[] updateCount to int[] updateCount.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   518
   * No checks for overflow will be done as it is expected a  user will call
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   519
   * getLargeUpdateCounts.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   520
   */
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   521
  private static int[] copyUpdateCount(long[] uc) {
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   522
      int[] copy = new int[uc.length];
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   523
      for(int i= 0; i< uc.length; i++) {
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   524
          copy[i] = (int) uc[i];
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   525
      }
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   526
      return copy;
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   527
  }
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   528
    /**
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   529
     * readObject is called to restore the state of the
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   530
     * {@code BatchUpdateException} from a stream.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   531
     */
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   532
    private void readObject(ObjectInputStream s)
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   533
            throws IOException, ClassNotFoundException {
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   534
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   535
       ObjectInputStream.GetField fields = s.readFields();
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   536
       int[] tmp = (int[])fields.get("updateCounts", null);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   537
       long[] tmp2 = (long[])fields.get("longUpdateCounts", null);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   538
       if(tmp != null && tmp2 != null && tmp.length != tmp2.length)
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   539
           throw new InvalidObjectException("update counts are not the expected size");
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   540
       if (tmp != null)
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   541
           updateCounts = tmp.clone();
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   542
       if (tmp2 != null)
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   543
           longUpdateCounts = tmp2.clone();
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   544
       if(updateCounts == null && longUpdateCounts != null)
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   545
           updateCounts = copyUpdateCount(longUpdateCounts);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   546
       if(longUpdateCounts == null && updateCounts != null)
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   547
           longUpdateCounts = copyUpdateCount(updateCounts);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   548
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   549
    }
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   550
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   551
    /**
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   552
     * writeObject is called to save the state of the {@code BatchUpdateException}
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   553
     * to a stream.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   554
     */
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   555
    private void writeObject(ObjectOutputStream s)
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   556
            throws IOException, ClassNotFoundException {
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   557
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   558
        ObjectOutputStream.PutField fields = s.putFields();
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   559
        fields.put("updateCounts", updateCounts);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   560
        fields.put("longUpdateCounts", longUpdateCounts);
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   561
        s.writeFields();
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 9777
diff changeset
   562
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
}