/projects/derby-10.9.1.0/db-derby-10.9.1.0-src/java/stubs/jdbc3/java/sql/BatchUpdateException.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus · Java · 147 lines · 30 code · 11 blank · 106 comment · 0 complexity · bafd1543c65bb3e0f13d9d0790402e8e MD5 · raw file

  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package java.sql;
  18. import java.io.Serializable;
  19. /**
  20. * An exception thrown if a problem occurs during a batch update operation.
  21. * <p>
  22. * A BatchUpdateException provides additional information about the problem that
  23. * occurred, compared with a standard SQLException. It supplies update counts
  24. * for successful commands that executed within the batch update, but before the
  25. * exception was encountered.
  26. * <p>
  27. * The element order in the array of update counts matches the order that the
  28. * commands were added to the batch operation.
  29. * <p>
  30. * Once a batch update command fails and a BatchUpdateException is thrown, the
  31. * JDBC driver may continue processing the remaining commands in the batch. If
  32. * the driver does process more commands after the problem occurs, the array
  33. * returned by BatchUpdateException.getUpdateCounts has an element for every
  34. * command in the batch, not only those that executed successfully. In this
  35. * case, the array element for any command which encountered a problem is set to
  36. * Statement.EXECUTE_FAILED.
  37. */
  38. public class BatchUpdateException extends SQLException implements Serializable {
  39. private static final long serialVersionUID = 5977529877145521757L;
  40. private int[] updateCounts = null;
  41. /**
  42. * Creates a BatchUpdateException with the Reason, SQLState, and Update
  43. * Counts set to null and a Vendor Code of 0.
  44. */
  45. public BatchUpdateException() {
  46. super();
  47. }
  48. /**
  49. * Creates a BatchUpdateException with the Update Counts set to the supplied
  50. * value and the Reason, SQLState set to null and a Vendor Code of 0.
  51. *
  52. * @param updateCounts
  53. * the array of Update Counts to use in initialization
  54. */
  55. public BatchUpdateException(int[] updateCounts) {
  56. super();
  57. this.updateCounts = updateCounts;
  58. }
  59. /**
  60. * Creates a BatchUpdateException with the Update Counts set to the supplied
  61. * value, the Reason set to the supplied value and SQLState set to null and
  62. * a Vendor Code of 0.
  63. *
  64. * @param reason
  65. * the initialization value for Reason
  66. * @param updateCounts
  67. * the array of Update Counts to set
  68. */
  69. public BatchUpdateException(String reason, int[] updateCounts) {
  70. super(reason);
  71. this.updateCounts = updateCounts;
  72. }
  73. /**
  74. * Creates a BatchUpdateException with the Update Counts set to the supplied
  75. * value, the Reason set to the supplied value, the SQLState initialized to
  76. * the supplied value and the Vendor Code initialized to 0.
  77. *
  78. * @param reason
  79. * the value to use for the Reason
  80. * @param SQLState
  81. * the X/OPEN value to use for the SQLState
  82. * @param updateCounts
  83. * the array of Update Counts to set
  84. */
  85. public BatchUpdateException(String reason, String SQLState,
  86. int[] updateCounts) {
  87. super(reason, SQLState);
  88. this.updateCounts = updateCounts;
  89. }
  90. /**
  91. * Creates a BatchUpdateException with the Update Counts set to the supplied
  92. * value, the Reason set to the supplied value, the SQLState initialized to
  93. * the supplied value and the Vendor Code set to the supplied value.
  94. *
  95. * @param reason
  96. * the value to use for the Reason
  97. * @param SQLState
  98. * the X/OPEN value to use for the SQLState
  99. * @param vendorCode
  100. * the value to use for the vendor error code
  101. * @param updateCounts
  102. * the array of Update Counts to set
  103. */
  104. public BatchUpdateException(String reason, String SQLState, int vendorCode,
  105. int[] updateCounts) {
  106. super(reason, SQLState, vendorCode);
  107. this.updateCounts = updateCounts;
  108. }
  109. /**
  110. * Gets the Update Counts array.
  111. * <p>
  112. * If a batch update command fails and a BatchUpdateException is thrown, the
  113. * JDBC driver may continue processing the remaining commands in the batch.
  114. * If the driver does process more commands after the problem occurs, the
  115. * array returned by <code>BatchUpdateException.getUpdateCounts</code> has
  116. * an element for every command in the batch, not only those that executed
  117. * successfully. In this case, the array element for any command which
  118. * encountered a problem is set to Statement.EXECUTE_FAILED.
  119. *
  120. * @return an array that contains the successful update counts, before this
  121. * exception. Alternatively, if the driver continues to process
  122. * commands following an error, one of these listed items for every
  123. * command the batch contains:
  124. * <ol>
  125. * <li>an count of the updates</li>
  126. * <li><code>Statement.SUCCESS_NO_INFO</code> indicating that the
  127. * command completed successfully, but the amount of altered rows is
  128. * not known.</li>
  129. * <li><code>Statement.EXECUTE_FAILED</code> indicating that the
  130. * command was unsuccessful.
  131. * </ol>
  132. */
  133. public int[] getUpdateCounts() {
  134. return updateCounts;
  135. }
  136. }