1 /* SQLException.java -- General SQL exception
2 Copyright (C) 1999, 2000 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 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)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 As a special exception, if you link this library with other files to
22 produce an executable, this library does not by itself cause the
23 resulting executable to be covered by the GNU General Public License.
24 This exception does not however invalidate any other reasons why the
25 executable file might be covered by the GNU General Public License. */
31 * This exception is thrown when a database error occurs.
33 * @author Aaron M. Renn (arenn@urbanophile.com)
35 public class SQLException extends Exception
38 /*************************************************************************/
45 * This is the next exception in the chain
48 private SQLException next;
51 * This is the state of the SQL statement at the time of the error.
54 private String SQLState;
57 * The vendor error code for this error
60 private int vendorCode;
62 /*************************************************************************/
69 * This is the serialization UID for this class
71 private static final long serialVersionUID = 2135244094396331484L;
73 /*************************************************************************/
80 * This method initializes a new instance of <code>SQLException</code>
81 * that does not have a descriptive messages and SQL state, and which
82 * has a vendor error code of 0.
90 /*************************************************************************/
93 * This method initializes a new instance of <code>SQLException</code>
94 * with the specified descriptive error message. The SQL state of this
95 * instance will be <code>null</code> and the vendor error code will be 0.
97 * @param message A string describing the nature of the error.
100 SQLException(String message)
102 this(message, null, 0);
105 /*************************************************************************/
108 * This method initializes a new instance of <code>SQLException</code>
109 * with the specified descriptive error message and SQL state string.
110 * The vendor error code of this instance will be 0.
112 * @param message A string describing the nature of the error.
113 * @param SQLState A string containing the SQL state of the error.
116 SQLException(String message, String SQLState)
118 this(message, SQLState, 0);
121 /*************************************************************************/
124 * This method initializes a nwe instance of <code>SQLException</code>
125 * with the specified descriptive error message, SQL state string, and
128 * @param message A string describing the nature of the error.
129 * @param SQLState A string containing the SQL state of the error.
130 * @param vendorCode The vendor error code associated with this error.
133 SQLException(String message, String SQLState, int vendorCode)
137 this.SQLState = SQLState;
138 this.vendorCode = vendorCode;
141 /*************************************************************************/
148 * This method returns the SQLState information associated with this
149 * error. The value returned is a <code>String</code> which is formatted
150 * using the XOPEN SQL state conventions.
152 * @return The SQL state, which may be <code>null</code>.
160 /*************************************************************************/
163 * This method returns the vendor specific error code associated with
166 * @return The vendor specific error code associated with this error.
174 /*************************************************************************/
177 * This method returns the exception that is chained to this object.
179 * @return The exception chained to this object, which may be
188 /*************************************************************************/
191 * This method adds a new exception to the end of the chain of exceptions
192 * that are chained to this object.
194 * @param e The exception to add to the end of the chain.
197 setNextException(SQLException e)
202 SQLException list_entry = this;
203 while (list_entry.getNextException() != null)
204 list_entry = list_entry.getNextException();
209 } // class SQLException