1. /*
  2. * @(#)BatchUpdateException.java 1.11 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.sql;
  8. /**
  9. * JDBC 2.0
  10. *
  11. * <P>
  12. * An exception thrown when an error
  13. * occurs during a batch update operation. In addition to the
  14. * information provided by {@link SQLException}, a
  15. * <code>BatchUpdateException</code> provides the update
  16. * counts for all commands that were executed successfully during the
  17. * batch update, that is, all commands that were executed before the error
  18. * occurred. The order of elements in an array of update counts
  19. * corresponds to the order in which commands were added to the batch.
  20. */
  21. public class BatchUpdateException extends SQLException {
  22. /**
  23. * Constructs a fully specified <code>BatchUpdateException</code>.
  24. * @param reason a description of the error
  25. * @param SQLState an X/OPEN code identifying the error
  26. * @param vendorCode an exception code for a particular
  27. * database vendor
  28. * @param updateCounts an array of <code>int</code>, with each element
  29. * indicating the update count for a SQL command that executed
  30. * successfully before the exception was thrown
  31. */
  32. public BatchUpdateException( String reason, String SQLState, int vendorCode,
  33. int[] updateCounts ) {
  34. super(reason, SQLState, vendorCode);
  35. this.updateCounts = updateCounts;
  36. }
  37. /**
  38. * Constructs a <code>BatchUpdateException</code> initialized with
  39. * the given arguments (<code>reason</code>,
  40. * <code>SQLState</code>, and <code>updateCounts</code>) and 0 for the vendor
  41. * code.
  42. * @param reason a description of the exception
  43. * @param SQLState an X/OPEN code identifying the exception
  44. * @param updateCounts an array of <code>int</code>, with each element
  45. * indicating the update count for a SQL command that executed
  46. * successfully before the exception was thrown
  47. */
  48. public BatchUpdateException(String reason, String SQLState,
  49. int[] updateCounts) {
  50. super(reason, SQLState);
  51. this.updateCounts = updateCounts;
  52. }
  53. /**
  54. * Constructs a <code>BatchUpdateException</code> initialized with
  55. * <code>reason</code>, <code>updateCounts</code> and <code>null</code>
  56. * for the SQLState and 0 for the vendorCode.
  57. * @param reason a description of the exception
  58. * @param updateCounts an array of <code>int</code>, with each element
  59. * indicating the update count for a SQL command that executed
  60. * successfully before the exception was thrown
  61. */
  62. public BatchUpdateException(String reason, int[] updateCounts) {
  63. super(reason);
  64. this.updateCounts = updateCounts;
  65. }
  66. /**
  67. * Constructs a <code>BatchUpdateException</code> initialized to
  68. * <code>null</code> for the reason and SQLState and 0 for the
  69. * vendor code.
  70. * @param updateCounts an array of <code>int</code>, with each element
  71. * indicating the update count for a SQL command that executed
  72. * successfully before the exception was thrown
  73. */
  74. public BatchUpdateException(int[] updateCounts) {
  75. super();
  76. this.updateCounts = updateCounts;
  77. }
  78. /**
  79. * Constructs a <code>BatchUpdateException</code> object
  80. * with the reason, SQLState, and update count initialized to
  81. * <code>null</code> and the vendor code initialized to 0.
  82. */
  83. public BatchUpdateException() {
  84. super();
  85. this.updateCounts = null;
  86. }
  87. /**
  88. * Retrieves the update count for each update statement in the batch
  89. * update that executed successfully before this exception occurred.
  90. * @return an array of <code>int</code> containing the update counts
  91. * for the updates that were executed successfully before this error
  92. * occurred
  93. */
  94. public int[] getUpdateCounts() {
  95. return updateCounts;
  96. }
  97. /**
  98. * @serial
  99. */
  100. private int[] updateCounts;
  101. }