1 /*
2 * Copyright 2004-2022 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 /**
26 * Constructor from java.sql.SQLException
27 *
28 * @param msg
29 * - the message for the exception
30 *
31 * @see java.sql.SQLException
32 */
33 public NestedSQLException(String msg) {
34 super(msg);
35 }
36
37 /**
38 * Constructor from java.sql.SQLException
39 *
40 * @param reason
41 * - the reason for the exception
42 * @param SQLState
43 * - the SQLState
44 *
45 * @see java.sql.SQLException
46 */
47 public NestedSQLException(String reason, String SQLState) {
48 super(reason, SQLState);
49 }
50
51 /**
52 * Constructor from java.sql.SQLException
53 *
54 * @param reason
55 * - the reason for the exception
56 * @param SQLState
57 * - the SQLState
58 * @param vendorCode
59 * - a vendor supplied code to go w/ the message
60 *
61 * @see java.sql.SQLException
62 */
63 public NestedSQLException(String reason, String SQLState, int vendorCode) {
64 super(reason, SQLState, vendorCode);
65 }
66
67 /**
68 * Constructor from java.sql.SQLException with added nested exception
69 *
70 * @param msg
71 * - the message for the exception
72 * @param cause
73 * - the cause of the exception
74 */
75 public NestedSQLException(String msg, Throwable cause) {
76 super(msg);
77 initCause(cause);
78 }
79
80 /**
81 * Constructor from java.sql.SQLException with added nested exception
82 *
83 * @param reason
84 * - the reason for the exception
85 * @param SQLState
86 * - the SQLState
87 * @param cause
88 * - the cause of the exception
89 *
90 * @see java.sql.SQLException
91 */
92 public NestedSQLException(String reason, String SQLState, Throwable cause) {
93 super(reason, SQLState);
94 initCause(cause);
95 }
96
97 /**
98 * Constructor from java.sql.SQLException with added nested exception
99 *
100 * @param reason
101 * - the reason for the exception
102 * @param SQLState
103 * - the SQLState
104 * @param vendorCode
105 * - a vendor supplied code to go w/ the message
106 * @param cause
107 * - the cause of the exception
108 */
109 public NestedSQLException(String reason, String SQLState, int vendorCode, Throwable cause) {
110 super(reason, SQLState, vendorCode);
111 initCause(cause);
112 }
113
114 /**
115 * Constructor from java.sql.SQLException with added nested exception
116 *
117 * @param cause
118 * - the cause of the exception
119 */
120 public NestedSQLException(Throwable cause) {
121 super();
122 initCause(cause);
123 }
124 }