• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2006, 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 in situations where a
30  * previously failed operation might be able to succeed if the application performs
31  *  some recovery steps and retries the entire transaction or in the case of a
32  * distributed transaction, the transaction branch.  At a minimum,
33  * the recovery operation must include closing the current connection and getting
34  * a new connection.
35  *<p>
36  *
37  * @since 1.6
38  */
39 public class SQLRecoverableException extends java.sql.SQLException {
40 
41         /**
42          * Constructs a <code>SQLRecoverableException</code> object.
43          * The <code>reason</code>, <code>SQLState</code> are initialized
44          * to <code>null</code> and the vendor code is initialized to 0.
45          *
46          * The <code>cause</code> is not initialized, and may subsequently be
47          * initialized by a call to the
48          * {@link Throwable#initCause(java.lang.Throwable)} method.
49          * <p>
50          * @since 1.6
51         */
SQLRecoverableException()52         public SQLRecoverableException() {
53                 super();
54         }
55 
56         /**
57          * Constructs a <code>SQLRecoverableException</code> object
58          *  with a given <code>reason</code>. The <code>SQLState</code>
59          * is initialized to <code>null</code> and the vender code is initialized
60          * to 0.
61          *
62          * The <code>cause</code> is not initialized, and may subsequently be
63          * initialized by a call to the
64          * {@link Throwable#initCause(java.lang.Throwable)} method.
65          * <p>
66          * @param reason a description of the exception
67          * @since 1.6
68          */
SQLRecoverableException(String reason)69         public SQLRecoverableException(String reason) {
70                 super(reason);
71         }
72 
73         /**
74          * Constructs a <code>SQLRecoverableException</code> object
75          * with a given <code>reason</code> and <code>SQLState</code>.
76          *
77          * The <code>cause</code> is not initialized, and may subsequently be
78          * initialized by a call to the
79          * {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
80          * is initialized to 0.
81          * <p>
82          * @param reason a description of the exception
83          * @param SQLState an XOPEN or SQL:2003 code identifying the exception
84          * @since 1.6
85          */
SQLRecoverableException(String reason, String SQLState)86         public SQLRecoverableException(String reason, String SQLState) {
87                 super(reason, SQLState);
88         }
89 
90         /**
91          * Constructs a <code>SQLRecoverableException</code> object
92          *  with a given <code>reason</code>, <code>SQLState</code>  and
93          * <code>vendorCode</code>.
94          *
95          * The <code>cause</code> is not initialized, and may subsequently be
96          * initialized by a call to the
97          * {@link Throwable#initCause(java.lang.Throwable)} method.
98          * <p>
99          * @param reason a description of the exception
100          * @param SQLState an XOPEN or SQL:2003 code identifying the exception
101          * @param vendorCode a database vendor specific exception code
102          * @since 1.6
103          */
SQLRecoverableException(String reason, String SQLState, int vendorCode)104         public SQLRecoverableException(String reason, String SQLState, int vendorCode) {
105                 super(reason, SQLState, vendorCode);
106         }
107 
108     /**
109      * Constructs a <code>SQLRecoverableException</code> object
110      * with a given  <code>cause</code>.
111      * The <code>SQLState</code> is initialized
112      * to <code>null</code> and the vendor code is initialized to 0.
113      * The <code>reason</code>  is initialized to <code>null</code> if
114      * <code>cause==null</code> or to <code>cause.toString()</code> if
115      * <code>cause!=null</code>.
116      * <p>
117      * @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
118      *     the cause is non-existent or unknown.
119      * @since 1.6
120      */
SQLRecoverableException(Throwable cause)121     public SQLRecoverableException(Throwable cause) {
122         super(cause);
123     }
124 
125     /**
126      * Constructs a <code>SQLRecoverableException</code> object
127      * 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      */
SQLRecoverableException(String reason, Throwable cause)137     public SQLRecoverableException(String reason, Throwable cause) {
138         super(reason, cause);
139     }
140 
141     /**
142      * Constructs a <code>SQLRecoverableException</code> object
143      * with a given
144      * <code>reason</code>, <code>SQLState</code> and  <code>cause</code>.
145      * The vendor code is initialized to 0.
146      * <p>
147      * @param reason a description of the exception.
148      * @param SQLState an XOPEN or SQL:2003 code identifying the exception
149      * @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
150      *     the cause is non-existent or unknown.
151      * @since 1.6
152      */
SQLRecoverableException(String reason, String SQLState, Throwable cause)153     public SQLRecoverableException(String reason, String SQLState, Throwable cause) {
154         super(reason, SQLState, cause);
155     }
156 
157     /**
158      *  Constructs a <code>SQLRecoverableException</code> object
159      * with a given
160      * <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
161      * and  <code>cause</code>.
162      * <p>
163      * @param reason a description of the exception
164      * @param SQLState an XOPEN or SQL:2003 code identifying the exception
165      * @param vendorCode a database vendor-specific exception code
166      * @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
167      *     the cause is non-existent or unknown.
168      * @since 1.6
169      */
SQLRecoverableException(String reason, String SQLState, int vendorCode, Throwable cause)170     public SQLRecoverableException(String reason, String SQLState, int vendorCode, Throwable cause) {
171         super(reason, SQLState, vendorCode, cause);
172     }
173 
174    private static final long serialVersionUID = -4144386502923131579L;
175 }
176