001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package java.sql;
019:
020: import java.io.Serializable;
021:
022: import org.apache.harmony.sql.internal.nls.Messages;
023:
024: /**
025: * An exception class that holds information about Database access warnings.
026: */
027: public class SQLWarning extends SQLException implements Serializable {
028:
029: private static final long serialVersionUID = 3917336774604784856L;
030:
031: /**
032: * Creates an SQLWarning object. The Reason string is set to null, the
033: * SQLState string is set to null and the Error Code is set to 0.
034: */
035: public SQLWarning() {
036: super ();
037: }
038:
039: /**
040: * Creates an SQLWarning object. The Reason string is set to the given
041: * reason string, the SQLState string is set to null and the Error Code is
042: * set to 0.
043: *
044: * @param theReason
045: */
046: public SQLWarning(String theReason) {
047: super (theReason);
048: }
049:
050: /**
051: * Creates an SQLWarning object. The Reason string is set to the given
052: * reason string, the SQLState string is set to the given SQLState string
053: * and the Error Code is set to 0.
054: *
055: * @param theReason
056: * the string to use as the Reason string
057: * @param theSQLState
058: * the string to use as the SQLState string
059: */
060: public SQLWarning(String theReason, String theSQLState) {
061: super (theReason, theSQLState);
062: }
063:
064: /**
065: * Creates an SQLWarning object. The Reason string is set to the given
066: * reason string, the SQLState string is set to the given SQLState string
067: * and the Error Code is set to the given ErrorCode value.
068: *
069: * @param theReason
070: * @param theSQLState
071: * @param theErrorCode
072: */
073: public SQLWarning(String theReason, String theSQLState,
074: int theErrorCode) {
075: super (theReason, theSQLState, theErrorCode);
076: }
077:
078: /**
079: * Gets the SQLWarning chained to this SQLWarning object.
080: *
081: * @return the SQLWarning chained to this SQLWarning. null if no SQLWarning
082: * is chained to this SQLWarning.
083: */
084: public SQLWarning getNextWarning() {
085: SQLException next = super .getNextException();
086: if (next == null) {
087: return null;
088: }
089: if (next instanceof SQLWarning) {
090: return (SQLWarning) next;
091: }
092: throw new Error(Messages.getString("sql.8")); //$NON-NLS-1$
093: }
094:
095: /**
096: * Chains a supplied SQLWarning to this SQLWarning.
097: *
098: * @param w
099: * the SQLWarning to chain to this SQLWarning.
100: */
101: public void setNextWarning(SQLWarning w) {
102: super.setNextException(w);
103: }
104: }
|