1 |
/* SQLWarning.java -- database access warnings |
/* SQLWarning.java -- Database access warnings. |
2 |
Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc. |
Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
7 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
8 |
the Free Software Foundation; either version 2, or (at your option) |
the Free Software Foundation; either version 2, or (at your option) |
9 |
any later version. |
any later version. |
10 |
|
|
11 |
GNU Classpath is distributed in the hope that it will be useful, but |
GNU Classpath is distributed in the hope that it will be useful, but |
12 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
39 |
package java.sql; |
package java.sql; |
40 |
|
|
41 |
/** |
/** |
42 |
* This exception is thrown when a database warning occurs. Warnings are |
* This exception is thrown when a database warning occurs. |
|
* silently chained to the object which caused them. |
|
|
* |
|
|
* <p>Warnings may be retrieved from <code>Connection</code>, |
|
|
* <code>Statement</code>, and <code>ResultSet</code> objects. Trying to |
|
|
* retrieve a warning one of these after it has been closed will cause an |
|
|
* exception to be thrown. Note that closing a statement also closes a result |
|
|
* set that it might have produced. |
|
43 |
* |
* |
44 |
* @author Aaron M. Renn (arenn@urbanophile.com) |
* @author Aaron M. Renn (arenn@urbanophile.com) |
|
* @see Connection#getWarnings() |
|
|
* @see Statement#getWarnings() |
|
|
* @see ResultSet#getWarnings() |
|
45 |
*/ |
*/ |
46 |
public class SQLWarning extends SQLException |
public class SQLWarning extends SQLException |
47 |
{ |
{ |
48 |
/** |
static final long serialVersionUID = 3917336774604784856L; |
|
* Compatible with JDK 1.1+. |
|
|
*/ |
|
|
private static final long serialVersionUID = 3917336774604784856L; |
|
49 |
|
|
50 |
/** |
/** |
51 |
* Create a new instance that does not have a descriptive messages or SQL |
* This method initializes a nwe instance of <code>SQLWarning</code> |
52 |
* state, and which has a vendor error code of 0. |
* with the specified descriptive error message, SQL state string, and |
53 |
|
* vendor code. |
54 |
|
* |
55 |
|
* @param message A string describing the nature of the error. |
56 |
|
* @param SQLState A string containing the SQL state of the error. |
57 |
|
* @param vendorCode The vendor error code associated with this error. |
58 |
*/ |
*/ |
59 |
public SQLWarning() |
public SQLWarning(String reason, String SQLState, int vendorCode) |
60 |
{ |
{ |
61 |
|
super(reason, SQLState, vendorCode); |
62 |
} |
} |
63 |
|
|
64 |
/** |
/** |
65 |
* Create a new instance with the specified descriptive error message. |
* This method initializes a new instance of <code>SQLWarning</code> |
66 |
* The SQL state of this instance will be <code>null</code> and the vendor |
* with the specified descriptive error message and SQL state string. |
67 |
* error code will be 0. |
* The vendor error code of this instance will be 0. |
68 |
* |
* |
69 |
* @param message a string describing the nature of the error |
* @param message A string describing the nature of the error. |
70 |
|
* @param SQLState A string containing the SQL state of the error. |
71 |
*/ |
*/ |
72 |
public SQLWarning(String message) |
public SQLWarning(String message, String SQLState) |
73 |
{ |
{ |
74 |
super(message); |
super(message, SQLState); |
75 |
} |
} |
76 |
|
|
77 |
/** |
/** |
78 |
* Create a new instance with the specified descriptive error message |
* This method initializes a new instance of <code>SQLWarning</code> |
79 |
* and SQL state string. The vendor error code of this instance will be 0. |
* with the specified descriptive error message. The SQL state of this |
80 |
|
* instance will be <code>null</code> and the vendor error code will be 0. |
81 |
* |
* |
82 |
* @param message a string describing the nature of the error |
* @param message A string describing the nature of the error. |
|
* @param SQLState a string containing the SQL state of the error |
|
83 |
*/ |
*/ |
84 |
public SQLWarning(String message, String SQLState) |
public SQLWarning(String message) |
85 |
{ |
{ |
86 |
super(message, SQLState); |
super(message); |
87 |
} |
} |
88 |
|
|
89 |
/** |
/** |
90 |
* Create a new instance with the specified descriptive error message, |
* This method initializes a new instance of <code>SQLWarning</code> |
91 |
* SQL state string, and vendor code. |
* that does not have a descriptive messages and SQL state, and which |
92 |
* |
* has a vendor error code of 0. |
|
* @param message a string describing the nature of the error |
|
|
* @param SQLState a string containing the SQL state of the error |
|
|
* @param vendorCode the vendor error code associated with this error |
|
93 |
*/ |
*/ |
94 |
public SQLWarning(String message, String SQLState, int vendorCode) |
public SQLWarning() |
95 |
{ |
{ |
96 |
super(message, SQLState, vendorCode); |
super(); |
97 |
} |
} |
98 |
|
|
99 |
/** |
/** |
100 |
* Get the warning that is chained to this object. |
* This method returns the exception that is chained to this object. |
101 |
* |
* |
102 |
* @return the exception chained to this object, or null |
* @return The exception chained to this object, which may be |
103 |
* @throws Error if the next element is not an SQLWarning |
* <code>null</code>. |
104 |
*/ |
*/ |
105 |
public SQLWarning getNextWarning() |
public SQLWarning getNextWarning() |
106 |
{ |
{ |
107 |
if (next == null) |
return (SQLWarning) super.getNextException(); |
|
return null; |
|
|
if (! (next instanceof SQLWarning)) |
|
|
throw new Error("SQLWarning chain holds value that is not a SQLWarning"); |
|
|
return (SQLWarning) next; |
|
108 |
} |
} |
109 |
|
|
110 |
/** |
/** |
111 |
* Set the new end of the warning chain. |
* This method adds a new exception to the end of the chain of exceptions |
112 |
|
* that are chained to this object. |
113 |
* |
* |
114 |
* @param e the exception to add to the end of the chain |
* @param w The exception to add to the end of the chain. |
115 |
*/ |
*/ |
116 |
public void setNextWarning(SQLWarning e) |
public void setNextWarning(SQLWarning w) |
117 |
{ |
{ |
118 |
setNextException(e); |
super.setNextException(w); |
119 |
} |
} |
120 |
} // class SQLWarning |
} |