1 /*
2  * Copyright (c) 2005, 2010, 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  * The subclass of {@link SQLException} thrown when the SQLState class value
30  * is '<i>22</i>', or under vendor-specified conditions.  This indicates
31  * various data errors, including but not limited to data conversion errors,
32  * division by 0, and invalid arguments to functions.
33  * <p>
34  * Please consult your driver vendor documentation for the vendor-specified
35  * conditions for which this <code>Exception</code> may be thrown.
36  * @since 1.6
37  */
38 public class SQLDataException extends SQLNonTransientException {
39 
40         /**
41          * Constructs a <code>SQLDataException</code> object.
42          * The <code>reason</code>, <code>SQLState</code> are initialized
43          * to <code>null</code> and the vendor code is initialized to 0.
44          *
45          * The <code>cause</code> is not initialized, and may subsequently be
46          * initialized by a call to
47          * {@link Throwable#initCause(java.lang.Throwable)} method.
48          * <p>
49          *
50          * @since 1.6
51          */
SQLDataException()52         public SQLDataException() {
53                  super();
54         }
55 
56         /**
57          * Constructs a <code>SQLDataException</code> object with a given
58          * <code>reason</code>.
59          * The <code>SQLState</code> is initialized
60          * to <code>null</code> and the vendor code is initialized to 0.
61          *
62          * The <code>cause</code> is not initialized, and may subsequently be
63          * initialized by a call to
64          * {@link Throwable#initCause(java.lang.Throwable)} method.
65          * <p>
66          *
67          * @param reason a description of the exception
68          * @since 1.6
69          */
SQLDataException(String reason)70         public SQLDataException(String reason) {
71                 super(reason);
72         }
73 
74         /**
75          * Constructs a <code>SQLDataException</code> object with a given
76          * <code>reason</code> and <code>SQLState</code>. The
77          * vendor code is initialized to 0.
78          *
79          * The <code>cause</code> is not initialized, and may subsequently be
80          * initialized by a call to
81          * {@link Throwable#initCause(java.lang.Throwable)} method.
82          * <p>
83          * @param reason a description of the exception
84          * @param SQLState an XOPEN or SQL:2003 code identifying the exception
85          * @since 1.6
86          */
SQLDataException(String reason, String SQLState)87         public SQLDataException(String reason, String SQLState) {
88                 super(reason, SQLState);
89         }
90 
91         /**
92          * Constructs a <code>SQLDataException</code> object with a given
93          * <code>reason</code>, <code>SQLState</code>  and
94          * <code>vendorCode</code>.
95          *
96          * The <code>cause</code> is not initialized, and may subsequently be
97          * initialized by a call to
98          * {@link Throwable#initCause(java.lang.Throwable)} method.
99          * <p>
100          * @param reason a description of the exception
101          * @param SQLState an XOPEN or SQL:2003 code identifying the exception
102          * @param vendorCode a database vendor specific exception code
103          * @since 1.6
104          */
SQLDataException(String reason, String SQLState, int vendorCode)105         public SQLDataException(String reason, String SQLState, int vendorCode) {
106                  super(reason, SQLState, vendorCode);
107         }
108 
109     /**
110      * Constructs a <code>SQLDataException</code> object with a given
111      * <code>cause</code>.
112      * The <code>SQLState</code> is initialized
113      * to <code>null</code> and the vendor code is initialized to 0.
114      * The <code>reason</code>  is initialized to <code>null</code> if
115      * <code>cause==null</code> or to <code>cause.toString()</code> if
116      * <code>cause!=null</code>.
117      * <p>
118      * @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
119      *     the cause is non-existent or unknown.
120      * @since 1.6
121          */
SQLDataException(Throwable cause)122     public SQLDataException(Throwable cause) {
123         super(cause);
124     }
125 
126     /**
127      * Constructs a <code>SQLDataException</code> object with a given
128      * <code>reason</code> and  <code>cause</code>.
129      * The <code>SQLState</code> is  initialized to <code>null</code>
130      * and the vendor code is initialized to 0.
131      * <p>
132      * @param reason a description of the exception.
133      * @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
134      *     the cause is non-existent or unknown.
135      * @since 1.6
136      */
SQLDataException(String reason, Throwable cause)137     public SQLDataException(String reason, Throwable cause) {
138          super(reason, cause);
139     }
140 
141     /**
142      *  Constructs a <code>SQLDataException</code> object with a given
143      * <code>reason</code>, <code>SQLState</code> and  <code>cause</code>.
144      * The vendor code is initialized to 0.
145      * <p>
146      * @param reason a description of the exception.
147      * @param SQLState an XOPEN or SQL:2003 code identifying the exception
148      * @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
149      *     the cause is non-existent or unknown.
150      * @since 1.6
151      */
SQLDataException(String reason, String SQLState, Throwable cause)152     public SQLDataException(String reason, String SQLState, Throwable cause) {
153         super(reason, SQLState, cause);
154     }
155 
156     /**
157      * Constructs a <code>SQLDataException</code> object with a given
158      * <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
159      * and  <code>cause</code>.
160      * <p>
161      * @param reason a description of the exception
162      * @param SQLState an XOPEN or SQL:2003 code identifying the exception
163      * @param vendorCode a database vendor-specific exception code
164      * @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
165      *     the cause is non-existent or unknown.
166      * @since 1.6
167      */
SQLDataException(String reason, String SQLState, int vendorCode, Throwable cause)168     public SQLDataException(String reason, String SQLState, int vendorCode, Throwable cause) {
169           super(reason, SQLState, vendorCode, cause);
170     }
171 
172    private static final long serialVersionUID = -6889123282670549800L;
173 }
174