KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > sql > SQLClientInfoException


1 /*
2  * @(#)SQLClientInfoException.java 1.2 06/07/10
3  *
4  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package java.sql;
8
9 import java.util.Map JavaDoc;
10
11 /**
12  * The subclass of {@link SQLException} is thrown when one or more client info properties
13  * could not be set on a <code>Connection</code>. In addition to the information provided
14  * by <code>SQLException</code>, a <code>SQLClientInfoException</code> provides a list of client info
15  * properties that were not set.
16  *
17  * Some databases do not allow multiple client info properties to be set
18  * atomically. For those databases, it is possible that some of the client
19  * info properties had been set even though the <code>Connection.setClientInfo</code>
20  * method threw an exception. An application can use the <code>getFailedProperties </code>
21  * method to retrieve a list of client info properties that were not set. The
22  * properties are identified by passing a
23  * <code>Map&lt;String,ClientInfoStatus&gt;</code> to
24  * the appropriate <code>SQLClientInfoException</code> constructor.
25  * <p>
26  * @see ClientInfoStatus
27  * @see Connection#setClientInfo
28  * @since 1.6
29  */

30 public class SQLClientInfoException extends SQLException JavaDoc {
31
32     
33     
34     
35     private Map JavaDoc<String JavaDoc, ClientInfoStatus JavaDoc> failedProperties;
36     
37     /**
38      * Constructs a <code>SQLClientInfoException</code> Object.
39      * The <code>reason</code>,
40      * <code>SQLState</code>, and failedProperties list are initialized to
41      * <code> null</code> and the vendor code is initialized to 0.
42      * The <code>cause</code> is not initialized, and may subsequently be
43      * initialized by a call to the
44      * {@link Throwable#initCause(java.lang.Throwable)} method.
45      * <p>
46      *
47      * @since 1.6
48      */

49     public SQLClientInfoException() {
50
51         this.failedProperties = null;
52     }
53
54     /**
55      * Constructs a <code>SQLClientInfoException</code> object initialized with a
56      * given <code>failedProperties</code>.
57      * The <code>reason</code> and <code>SQLState</code> are initialized
58      * to <code>null</code> and the vendor code is initialized to 0.
59      *
60      * The <code>cause</code> is not initialized, and may subsequently be
61      * initialized by a call to the
62      * {@link Throwable#initCause(java.lang.Throwable)} method.
63      * <p>
64      *
65      * @param failedProperties A Map containing the property values that could not
66      * be set. The keys in the Map
67      * contain the names of the client info
68      * properties that could not be set and
69      * the values contain one of the reason codes
70      * defined in <code>ClientInfoStatus</code>
71      * <p>
72      * @since 1.6
73      */

74     public SQLClientInfoException(Map JavaDoc<String JavaDoc, ClientInfoStatus JavaDoc> failedProperties) {
75
76         this.failedProperties = failedProperties;
77     }
78
79     /**
80      * Constructs a <code>SQLClientInfoException</code> object initialized with
81      * a given <code>cause</code> and <code>failedProperties</code>.
82      *
83      * The <code>reason</code> is initialized to <code>null</code> if
84      * <code>cause==null</code> or to <code>cause.toString()</code> if
85      * <code>cause!=null</code> and the vendor code is initialized to 0.
86      *
87      * <p>
88      *
89      * @param failedProperties A Map containing the property values that could not
90      * be set. The keys in the Map
91      * contain the names of the client info
92      * properties that could not be set and
93      * the values contain one of the reason codes
94      * defined in <code>ClientInfoStatus</code>
95      * @param cause the (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
96      * the cause is non-existent or unknown.
97      * <p>
98      * @since 1.6
99      */

100     public SQLClientInfoException(Map JavaDoc<String JavaDoc, ClientInfoStatus JavaDoc> failedProperties,
101                                Throwable JavaDoc cause) {
102
103                 super(cause != null?cause.toString():null);
104         initCause(cause);
105         this.failedProperties = failedProperties;
106     }
107
108     /**
109      * Constructs a <code>SQLClientInfoException</code> object initialized with a
110      * given <code>reason</code> and <code>failedProperties</code>.
111      * The <code>SQLState</code> is initialized
112      * to <code>null</code> and the vendor code is initialized to 0.
113      *
114      * The <code>cause</code> is not initialized, and may subsequently be
115      * initialized by a call to the
116      * {@link Throwable#initCause(java.lang.Throwable)} method.
117      * <p>
118      *
119      * @param reason a description of the exception
120      * @param failedProperties A Map containing the property values that could not
121      * be set. The keys in the Map
122      * contain the names of the client info
123      * properties that could not be set and
124      * the values contain one of the reason codes
125      * defined in <code>ClientInfoStatus</code>
126      * <p>
127      * @since 1.6
128      */

129     public SQLClientInfoException(String JavaDoc reason,
130                 Map JavaDoc<String JavaDoc, ClientInfoStatus JavaDoc> failedProperties) {
131
132         super(reason);
133         this.failedProperties = failedProperties;
134     }
135
136     /**
137      * Constructs a <code>SQLClientInfoException</code> object initialized with a
138      * given <code>reason</code>, <code>cause</code> and
139      * <code>failedProperties</code>.
140      * The <code>SQLState</code> is initialized
141      * to <code>null</code> and the vendor code is initialized to 0.
142      * <p>
143      *
144      * @param reason a description of the exception
145      * @param failedProperties A Map containing the property values that could not
146      * be set. The keys in the Map
147      * contain the names of the client info
148      * properties that could not be set and
149      * the values contain one of the reason codes
150      * defined in <code>ClientInfoStatus</code>
151      * @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
152      * the cause is non-existent or unknown.
153      * <p>
154      * @since 1.6
155      */

156     public SQLClientInfoException(String JavaDoc reason,
157                                Map JavaDoc<String JavaDoc, ClientInfoStatus JavaDoc> failedProperties,
158                                Throwable JavaDoc cause) {
159
160         super(reason);
161         initCause(cause);
162         this.failedProperties = failedProperties;
163     }
164
165     /**
166      * Constructs a <code>SQLClientInfoException</code> object initialized with a
167      * given <code>reason</code>, <code>SQLState</code> and
168      * <code>failedProperties</code>.
169      * The <code>cause</code> is not initialized, and may subsequently be
170      * initialized by a call to the
171      * {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
172      * is initialized to 0.
173      * <p>
174      *
175      * @param reason a description of the exception
176      * @param SQLState an XOPEN or SQL:2003 code identifying the exception
177      * @param failedProperties A Map containing the property values that could not
178      * be set. The keys in the Map
179      * contain the names of the client info
180      * properties that could not be set and
181      * the values contain one of the reason codes
182      * defined in <code>ClientInfoStatus</code>
183      * <p>
184      * @since 1.6
185      */

186     public SQLClientInfoException(String JavaDoc reason,
187                                String JavaDoc SQLState,
188                                Map JavaDoc<String JavaDoc, ClientInfoStatus JavaDoc> failedProperties) {
189
190         super(reason, SQLState);
191         this.failedProperties = failedProperties;
192     }
193
194     /**
195      * Constructs a <code>SQLClientInfoException</code> object initialized with a
196      * given <code>reason</code>, <code>SQLState</code>, <code>cause</code>
197      * and <code>failedProperties</code>. The vendor code is initialized to 0.
198      * <p>
199      *
200      * @param reason a description of the exception
201      * @param SQLState an XOPEN or SQL:2003 code identifying the exception
202      * @param failedProperties A Map containing the property values that could not
203      * be set. The keys in the Map
204      * contain the names of the client info
205      * properties that could not be set and
206      * the values contain one of the reason codes
207      * defined in <code>ClientInfoStatus</code>
208      * @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
209      * the cause is non-existent or unknown.
210      * <p>
211      * @since 1.6
212      */

213     public SQLClientInfoException(String JavaDoc reason,
214                                String JavaDoc SQLState,
215                                Map JavaDoc<String JavaDoc, ClientInfoStatus JavaDoc> failedProperties,
216                                Throwable JavaDoc cause) {
217
218         super(reason, SQLState);
219         initCause(cause);
220         this.failedProperties = failedProperties;
221     }
222
223     /**
224      * Constructs a <code>SQLClientInfoException</code> object initialized with a
225      * given <code>reason</code>, <code>SQLState</code>,
226      * <code>vendorCode</code> and <code>failedProperties</code>.
227      * The <code>cause</code> is not initialized, and may subsequently be
228      * initialized by a call to the
229      * {@link Throwable#initCause(java.lang.Throwable)} method.
230      * <p>
231      *
232      * @param reason a description of the exception
233      * @param SQLState an XOPEN or SQL:2003 code identifying the exception
234      * @param vendorCode a database vendor-specific exception code
235      * @param failedProperties A Map containing the property values that could not
236      * be set. The keys in the Map
237      * contain the names of the client info
238      * properties that could not be set and
239      * the values contain one of the reason codes
240      * defined in <code>ClientInfoStatus</code>
241      * <p>
242      * @since 1.6
243      */

244     public SQLClientInfoException(String JavaDoc reason,
245                                String JavaDoc SQLState,
246                                int vendorCode,
247                                Map JavaDoc<String JavaDoc, ClientInfoStatus JavaDoc> failedProperties) {
248         
249         super(reason, SQLState, vendorCode);
250         this.failedProperties = failedProperties;
251     }
252     
253     /**
254      * Constructs a <code>SQLClientInfoException</code> object initialized with a
255      * given <code>reason</code>, <code>SQLState</code>,
256      * <code>cause</code>, <code>vendorCode</code> and
257      * <code>failedProperties</code>.
258      * <p>
259      *
260      * @param reason a description of the exception
261      * @param SQLState an XOPEN or SQL:2003 code identifying the exception
262      * @param vendorCode a database vendor-specific exception code
263      * @param failedProperties A Map containing the property values that could not
264      * be set. The keys in the Map
265      * contain the names of the client info
266      * properties that could not be set and
267      * the values contain one of the reason codes
268      * defined in <code>ClientInfoStatus</code>
269      * @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
270      * the cause is non-existent or unknown.
271      * <p>
272      * @since 1.6
273      */

274     public SQLClientInfoException(String JavaDoc reason,
275                                String JavaDoc SQLState,
276                                int vendorCode,
277                                Map JavaDoc<String JavaDoc, ClientInfoStatus JavaDoc> failedProperties,
278                                Throwable JavaDoc cause) {
279
280         super(reason, SQLState, vendorCode);
281         initCause(cause);
282         this.failedProperties = failedProperties;
283     }
284     
285     /**
286      * Returns the list of client info properties that could not be set. The
287      * keys in the Map contain the names of the client info
288      * properties that could not be set and the values contain one of the
289      * reason codes defined in <code>ClientInfoStatus</code>
290      * <p>
291      *
292      * @return Map list containing the client info properties that could
293      * not be set
294      * <p>
295      * @since 1.6
296      */

297     public Map JavaDoc<String JavaDoc, ClientInfoStatus JavaDoc> getFailedProperties() {
298         
299         return this.failedProperties;
300     }
301
302     private static final long serialVersionUID = -4319604256824655880L;
303 }
304
Popular Tags