Debian Codegraph @

src/main/org/h2/jdbc/JdbcBatchUpdateException.java

raw
1 /*
2 * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (https://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6 package org.h2.jdbc;
7
8 import java.io.PrintStream;
9 import java.io.PrintWriter;
10 import java.sql.BatchUpdateException;
11 import java.sql.SQLException;
12
13 /**
14 * Represents a batch update database exception.
15 */
16 public final class JdbcBatchUpdateException extends BatchUpdateException {
17
18 private static final long serialVersionUID = 1L;
19
20 /**
21 * INTERNAL
22 * @param next exception
23 * @param updateCounts affected record counts
24 */
25 JdbcBatchUpdateException(SQLException next, int[] updateCounts) {
26 super(next.getMessage(), next.getSQLState(), next.getErrorCode(), updateCounts);
27 setNextException(next);
28 }
29
30 /**
31 * INTERNAL
32 * @param next exception
33 * @param updateCounts affected record counts
34 */
35 JdbcBatchUpdateException(SQLException next, long[] updateCounts) {
36 super(next.getMessage(), next.getSQLState(), next.getErrorCode(), updateCounts, null);
37 setNextException(next);
38 }
39
40 /**
41 * INTERNAL
42 */
43 @Override
44 public void printStackTrace() {
45 // The default implementation already does that,
46 // but we do it again to avoid problems.
47 // If it is not implemented, somebody might implement it
48 // later on which would be a problem if done in the wrong way.
49 printStackTrace(System.err);
50 }
51
52 /**
53 * INTERNAL
54 */
55 @Override
56 public void printStackTrace(PrintWriter s) {
57 if (s != null) {
58 super.printStackTrace(s);
59 if (getNextException() != null) {
60 getNextException().printStackTrace(s);
61 }
62 }
63 }
64
65 /**
66 * INTERNAL
67 */
68 @Override
69 public void printStackTrace(PrintStream s) {
70 if (s != null) {
71 super.printStackTrace(s);
72 if (getNextException() != null) {
73 getNextException().printStackTrace(s);
74 }
75 }
76 }
77
78 }