author | jcbeyler |
Wed, 14 Nov 2018 12:25:15 -0800 | |
changeset 52561 | 40098289d580 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
21278
diff
changeset
|
2 |
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package java.sql; |
|
27 |
||
28 |
/** |
|
29 |
* <P>An exception that provides information on database access |
|
30 |
* warnings. Warnings are silently chained to the object whose method |
|
31 |
* caused it to be reported. |
|
32 |
* <P> |
|
33 |
* Warnings may be retrieved from <code>Connection</code>, <code>Statement</code>, |
|
34 |
* and <code>ResultSet</code> objects. Trying to retrieve a warning on a |
|
35 |
* connection after it has been closed will cause an exception to be thrown. |
|
36 |
* Similarly, trying to retrieve a warning on a statement after it has been |
|
37 |
* closed or on a result set after it has been closed will cause |
|
38 |
* an exception to be thrown. Note that closing a statement also |
|
39 |
* closes a result set that it might have produced. |
|
40 |
* |
|
41 |
* @see Connection#getWarnings |
|
42 |
* @see Statement#getWarnings |
|
43 |
* @see ResultSet#getWarnings |
|
44256 | 44 |
* @since 1.1 |
2 | 45 |
*/ |
46 |
public class SQLWarning extends SQLException { |
|
47 |
||
48 |
/** |
|
49 |
* Constructs a <code>SQLWarning</code> object |
|
50 |
* with a given <code>reason</code>, <code>SQLState</code> and |
|
51 |
* <code>vendorCode</code>. |
|
52 |
* |
|
53 |
* The <code>cause</code> is not initialized, and may subsequently be |
|
54 |
* initialized by a call to the |
|
55 |
* {@link Throwable#initCause(java.lang.Throwable)} method. |
|
23590 | 56 |
* |
2 | 57 |
* @param reason a description of the warning |
58 |
* @param SQLState an XOPEN or SQL:2003 code identifying the warning |
|
59 |
* @param vendorCode a database vendor-specific warning code |
|
60 |
*/ |
|
61 |
public SQLWarning(String reason, String SQLState, int vendorCode) { |
|
62 |
super(reason, SQLState, vendorCode); |
|
63 |
DriverManager.println("SQLWarning: reason(" + reason + |
|
64 |
") SQLState(" + SQLState + |
|
65 |
") vendor code(" + vendorCode + ")"); |
|
66 |
} |
|
67 |
||
68 |
||
69 |
/** |
|
70 |
* Constructs a <code>SQLWarning</code> object |
|
71 |
* with a given <code>reason</code> and <code>SQLState</code>. |
|
72 |
* |
|
73 |
* The <code>cause</code> is not initialized, and may subsequently be |
|
74 |
* initialized by a call to the |
|
75 |
* {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code |
|
76 |
* is initialized to 0. |
|
23590 | 77 |
* |
2 | 78 |
* @param reason a description of the warning |
79 |
* @param SQLState an XOPEN or SQL:2003 code identifying the warning |
|
80 |
*/ |
|
81 |
public SQLWarning(String reason, String SQLState) { |
|
82 |
super(reason, SQLState); |
|
83 |
DriverManager.println("SQLWarning: reason(" + reason + |
|
84 |
") SQLState(" + SQLState + ")"); |
|
85 |
} |
|
86 |
||
87 |
/** |
|
88 |
* Constructs a <code>SQLWarning</code> object |
|
89 |
* with a given <code>reason</code>. The <code>SQLState</code> |
|
21278 | 90 |
* is initialized to <code>null</code> and the vendor code is initialized |
2 | 91 |
* to 0. |
92 |
* |
|
93 |
* The <code>cause</code> is not initialized, and may subsequently be |
|
94 |
* initialized by a call to the |
|
95 |
* {@link Throwable#initCause(java.lang.Throwable)} method. |
|
23590 | 96 |
* |
2 | 97 |
* @param reason a description of the warning |
98 |
*/ |
|
99 |
public SQLWarning(String reason) { |
|
100 |
super(reason); |
|
101 |
DriverManager.println("SQLWarning: reason(" + reason + ")"); |
|
102 |
} |
|
103 |
||
104 |
/** |
|
105 |
* Constructs a <code>SQLWarning</code> object. |
|
106 |
* The <code>reason</code>, <code>SQLState</code> are initialized |
|
107 |
* to <code>null</code> and the vendor code is initialized to 0. |
|
108 |
* |
|
109 |
* The <code>cause</code> is not initialized, and may subsequently be |
|
110 |
* initialized by a call to the |
|
111 |
* {@link Throwable#initCause(java.lang.Throwable)} method. |
|
20880
1b610151b316
8026812: doclint clean up for java.sql and javax.sql
lancea
parents:
5506
diff
changeset
|
112 |
* |
2 | 113 |
*/ |
114 |
public SQLWarning() { |
|
115 |
super(); |
|
116 |
DriverManager.println("SQLWarning: "); |
|
117 |
} |
|
118 |
||
119 |
/** |
|
120 |
* Constructs a <code>SQLWarning</code> object |
|
121 |
* with a given <code>cause</code>. |
|
122 |
* The <code>SQLState</code> is initialized |
|
123 |
* to <code>null</code> and the vendor code is initialized to 0. |
|
124 |
* The <code>reason</code> is initialized to <code>null</code> if |
|
125 |
* <code>cause==null</code> or to <code>cause.toString()</code> if |
|
126 |
* <code>cause!=null</code>. |
|
23590 | 127 |
* |
2 | 128 |
* @param cause the underlying reason for this <code>SQLWarning</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating |
129 |
* the cause is non-existent or unknown. |
|
130 |
*/ |
|
131 |
public SQLWarning(Throwable cause) { |
|
132 |
super(cause); |
|
133 |
DriverManager.println("SQLWarning"); |
|
134 |
} |
|
135 |
||
136 |
/** |
|
137 |
* Constructs a <code>SQLWarning</code> object |
|
138 |
* with a given |
|
139 |
* <code>reason</code> and <code>cause</code>. |
|
140 |
* The <code>SQLState</code> is initialized to <code>null</code> |
|
141 |
* and the vendor code is initialized to 0. |
|
23590 | 142 |
* |
2 | 143 |
* @param reason a description of the warning |
144 |
* @param cause the underlying reason for this <code>SQLWarning</code> |
|
145 |
* (which is saved for later retrieval by the <code>getCause()</code> method); |
|
146 |
* may be null indicating the cause is non-existent or unknown. |
|
147 |
*/ |
|
148 |
public SQLWarning(String reason, Throwable cause) { |
|
149 |
super(reason,cause); |
|
150 |
DriverManager.println("SQLWarning : reason("+ reason + ")"); |
|
151 |
} |
|
152 |
||
153 |
/** |
|
154 |
* Constructs a <code>SQLWarning</code> object |
|
155 |
* with a given |
|
156 |
* <code>reason</code>, <code>SQLState</code> and <code>cause</code>. |
|
157 |
* The vendor code is initialized to 0. |
|
23590 | 158 |
* |
2 | 159 |
* @param reason a description of the warning |
160 |
* @param SQLState an XOPEN or SQL:2003 code identifying the warning |
|
161 |
* @param cause the underlying reason for this <code>SQLWarning</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating |
|
162 |
* the cause is non-existent or unknown. |
|
163 |
*/ |
|
164 |
public SQLWarning(String reason, String SQLState, Throwable cause) { |
|
165 |
super(reason,SQLState,cause); |
|
166 |
DriverManager.println("SQLWarning: reason(" + reason + |
|
167 |
") SQLState(" + SQLState + ")"); |
|
168 |
} |
|
169 |
||
170 |
/** |
|
171 |
* Constructs a<code>SQLWarning</code> object |
|
172 |
* with a given |
|
173 |
* <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code> |
|
174 |
* and <code>cause</code>. |
|
23590 | 175 |
* |
2 | 176 |
* @param reason a description of the warning |
177 |
* @param SQLState an XOPEN or SQL:2003 code identifying the warning |
|
178 |
* @param vendorCode a database vendor-specific warning code |
|
179 |
* @param cause the underlying reason for this <code>SQLWarning</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating |
|
180 |
* the cause is non-existent or unknown. |
|
181 |
*/ |
|
182 |
public SQLWarning(String reason, String SQLState, int vendorCode, Throwable cause) { |
|
183 |
super(reason,SQLState,vendorCode,cause); |
|
184 |
DriverManager.println("SQLWarning: reason(" + reason + |
|
185 |
") SQLState(" + SQLState + |
|
186 |
") vendor code(" + vendorCode + ")"); |
|
187 |
||
188 |
} |
|
189 |
/** |
|
190 |
* Retrieves the warning chained to this <code>SQLWarning</code> object by |
|
191 |
* <code>setNextWarning</code>. |
|
192 |
* |
|
193 |
* @return the next <code>SQLException</code> in the chain; <code>null</code> if none |
|
194 |
* @see #setNextWarning |
|
195 |
*/ |
|
196 |
public SQLWarning getNextWarning() { |
|
197 |
try { |
|
198 |
return ((SQLWarning)getNextException()); |
|
199 |
} catch (ClassCastException ex) { |
|
200 |
// The chained value isn't a SQLWarning. |
|
201 |
// This is a programming error by whoever added it to |
|
202 |
// the SQLWarning chain. We throw a Java "Error". |
|
203 |
throw new Error("SQLWarning chain holds value that is not a SQLWarning"); |
|
204 |
} |
|
205 |
} |
|
206 |
||
207 |
/** |
|
208 |
* Adds a <code>SQLWarning</code> object to the end of the chain. |
|
209 |
* |
|
210 |
* @param w the new end of the <code>SQLException</code> chain |
|
211 |
* @see #getNextWarning |
|
212 |
*/ |
|
213 |
public void setNextWarning(SQLWarning w) { |
|
214 |
setNextException(w); |
|
215 |
} |
|
216 |
||
217 |
private static final long serialVersionUID = 3917336774604784856L; |
|
218 |
} |