1 /*
2 * Copyright 2004-2025 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package com.ibatis.common.jdbc.exception;
17
18 import java.sql.SQLException;
19
20 /**
21 * Class to allow passing an Exception with the original SQLException.
22 */
23 public class NestedSQLException extends SQLException {
24
25 /** The Constant serialVersionUID. */
26 private static final long serialVersionUID = 1L;
27
28 /**
29 * Constructor from java.sql.SQLException
30 *
31 * @param msg
32 * - the message for the exception
33 *
34 * @see java.sql.SQLException
35 */
36 public NestedSQLException(String msg) {
37 super(msg);
38 }
39
40 /**
41 * Constructor from java.sql.SQLException
42 *
43 * @param reason
44 * - the reason for the exception
45 * @param SQLState
46 * - the SQLState
47 *
48 * @see java.sql.SQLException
49 */
50 public NestedSQLException(String reason, String SQLState) {
51 super(reason, SQLState);
52 }
53
54 /**
55 * Constructor from java.sql.SQLException
56 *
57 * @param reason
58 * - the reason for the exception
59 * @param SQLState
60 * - the SQLState
61 * @param vendorCode
62 * - a vendor supplied code to go w/ the message
63 *
64 * @see java.sql.SQLException
65 */
66 public NestedSQLException(String reason, String SQLState, int vendorCode) {
67 super(reason, SQLState, vendorCode);
68 }
69
70 /**
71 * Constructor from java.sql.SQLException with added nested exception
72 *
73 * @param msg
74 * - the message for the exception
75 * @param cause
76 * - the cause of the exception
77 */
78 public NestedSQLException(String msg, Throwable cause) {
79 super(msg);
80 initCause(cause);
81 }
82
83 /**
84 * Constructor from java.sql.SQLException with added nested exception
85 *
86 * @param reason
87 * - the reason for the exception
88 * @param SQLState
89 * - the SQLState
90 * @param cause
91 * - the cause of the exception
92 *
93 * @see java.sql.SQLException
94 */
95 public NestedSQLException(String reason, String SQLState, Throwable cause) {
96 super(reason, SQLState);
97 initCause(cause);
98 }
99
100 /**
101 * Constructor from java.sql.SQLException with added nested exception
102 *
103 * @param reason
104 * - the reason for the exception
105 * @param SQLState
106 * - the SQLState
107 * @param vendorCode
108 * - a vendor supplied code to go w/ the message
109 * @param cause
110 * - the cause of the exception
111 */
112 public NestedSQLException(String reason, String SQLState, int vendorCode, Throwable cause) {
113 super(reason, SQLState, vendorCode);
114 initCause(cause);
115 }
116
117 /**
118 * Constructor from java.sql.SQLException with added nested exception
119 *
120 * @param cause
121 * - the cause of the exception
122 */
123 public NestedSQLException(Throwable cause) {
124 super();
125 initCause(cause);
126 }
127 }