Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.sql/share/classes/java/sql/SQLWarning.java
41153 views
1
/*
2
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
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
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
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
*
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.
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 Statement},
34
* and {@code ResultSet} 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
44
* @since 1.1
45
*/
46
public class SQLWarning extends SQLException {
47
48
/**
49
* Constructs a {@code SQLWarning} object
50
* with a given {@code reason}, {@code SQLState} and
51
* {@code vendorCode}.
52
*
53
* The {@code cause} is not initialized, and may subsequently be
54
* initialized by a call to the
55
* {@link Throwable#initCause(java.lang.Throwable)} method.
56
*
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} object
71
* with a given {@code reason} and {@code SQLState}.
72
*
73
* The {@code cause} 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.
77
*
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} object
89
* with a given {@code reason}. The {@code SQLState}
90
* is initialized to {@code null} and the vendor code is initialized
91
* to 0.
92
*
93
* The {@code cause} is not initialized, and may subsequently be
94
* initialized by a call to the
95
* {@link Throwable#initCause(java.lang.Throwable)} method.
96
*
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} object.
106
* The {@code reason}, {@code SQLState} are initialized
107
* to {@code null} and the vendor code is initialized to 0.
108
*
109
* The {@code cause} is not initialized, and may subsequently be
110
* initialized by a call to the
111
* {@link Throwable#initCause(java.lang.Throwable)} method.
112
*
113
*/
114
public SQLWarning() {
115
super();
116
DriverManager.println("SQLWarning: ");
117
}
118
119
/**
120
* Constructs a {@code SQLWarning} object
121
* with a given {@code cause}.
122
* The {@code SQLState} is initialized
123
* to {@code null} and the vendor code is initialized to 0.
124
* The {@code reason} is initialized to {@code null} if
125
* {@code cause==null} or to {@code cause.toString()} if
126
* {@code cause!=null}.
127
*
128
* @param cause the underlying reason for this {@code SQLWarning} (which is saved for later retrieval by the {@code getCause()} 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} object
138
* with a given
139
* {@code reason} and {@code cause}.
140
* The {@code SQLState} is initialized to {@code null}
141
* and the vendor code is initialized to 0.
142
*
143
* @param reason a description of the warning
144
* @param cause the underlying reason for this {@code SQLWarning}
145
* (which is saved for later retrieval by the {@code getCause()} 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} object
155
* with a given
156
* {@code reason}, {@code SQLState} and {@code cause}.
157
* The vendor code is initialized to 0.
158
*
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} (which is saved for later retrieval by the {@code getCause()} 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} object
172
* with a given
173
* {@code reason}, {@code SQLState}, {@code vendorCode}
174
* and {@code cause}.
175
*
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} (which is saved for later retrieval by the {@code getCause()} 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} object by
191
* {@code setNextWarning}.
192
*
193
* @return the next {@code SQLException} in the chain; {@code null} 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} object to the end of the chain.
209
*
210
* @param w the new end of the {@code SQLException} chain
211
* @see #getNextWarning
212
*/
213
public void setNextWarning(SQLWarning w) {
214
setNextException(w);
215
}
216
217
private static final long serialVersionUID = 3917336774604784856L;
218
}
219
220