Debian Codegraph @

src/main/org/h2/jdbc/JdbcSQLFeatureNotSupportedException.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.SQLFeatureNotSupportedException;
11
12 import org.h2.message.DbException;
13
14 /**
15 * Represents a database exception.
16 */
17 public final class JdbcSQLFeatureNotSupportedException extends SQLFeatureNotSupportedException
18 implements JdbcException {
19
20 private static final long serialVersionUID = 1L;
21
22 private final String originalMessage;
23 private final String stackTrace;
24 private String message;
25 private String sql;
26
27 /**
28 * Creates a SQLFeatureNotSupportedException.
29 *
30 * @param message the reason
31 * @param sql the SQL statement
32 * @param state the SQL state
33 * @param errorCode the error code
34 * @param cause the exception that was the reason for this exception
35 * @param stackTrace the stack trace
36 */
37 public JdbcSQLFeatureNotSupportedException(String message, String sql, String state,
38 int errorCode, Throwable cause, String stackTrace) {
39 super(message, state, errorCode);
40 this.originalMessage = message;
41 this.stackTrace = stackTrace;
42 // setSQL() also generates message
43 setSQL(sql);
44 initCause(cause);
45 }
46
47 @Override
48 public String getMessage() {
49 return message;
50 }
51
52 @Override
53 public String getOriginalMessage() {
54 return originalMessage;
55 }
56
57 @Override
58 public void printStackTrace(PrintWriter s) {
59 super.printStackTrace(s);
60 DbException.printNextExceptions(this, s);
61 }
62
63 @Override
64 public void printStackTrace(PrintStream s) {
65 super.printStackTrace(s);
66 DbException.printNextExceptions(this, s);
67 }
68
69 @Override
70 public String getSQL() {
71 return sql;
72 }
73
74 @Override
75 public void setSQL(String sql) {
76 this.sql = sql;
77 message = DbException.buildMessageForException(this);
78 }
79
80 @Override
81 public String toString() {
82 if (stackTrace == null) {
83 return super.toString();
84 }
85 return stackTrace;
86 }
87
88 }