Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/sql/SQLClientInfoException.java
38829 views
/*1* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24package java.sql;2526import java.util.Map;2728/**29* The subclass of {@link SQLException} is thrown when one or more client info properties30* could not be set on a <code>Connection</code>. In addition to the information provided31* by <code>SQLException</code>, a <code>SQLClientInfoException</code> provides a list of client info32* properties that were not set.33*34* Some databases do not allow multiple client info properties to be set35* atomically. For those databases, it is possible that some of the client36* info properties had been set even though the <code>Connection.setClientInfo</code>37* method threw an exception. An application can use the <code>getFailedProperties </code>38* method to retrieve a list of client info properties that were not set. The39* properties are identified by passing a40* <code>Map<String,ClientInfoStatus></code> to41* the appropriate <code>SQLClientInfoException</code> constructor.42* <p>43* @see ClientInfoStatus44* @see Connection#setClientInfo45* @since 1.646*/47public class SQLClientInfoException extends SQLException {4849505152private Map<String, ClientInfoStatus> failedProperties;5354/**55* Constructs a <code>SQLClientInfoException</code> Object.56* The <code>reason</code>,57* <code>SQLState</code>, and failedProperties list are initialized to58* <code> null</code> and the vendor code is initialized to 0.59* The <code>cause</code> is not initialized, and may subsequently be60* initialized by a call to the61* {@link Throwable#initCause(java.lang.Throwable)} method.62* <p>63*64* @since 1.665*/66public SQLClientInfoException() {6768this.failedProperties = null;69}7071/**72* Constructs a <code>SQLClientInfoException</code> object initialized with a73* given <code>failedProperties</code>.74* The <code>reason</code> and <code>SQLState</code> are initialized75* to <code>null</code> and the vendor code is initialized to 0.76*77* The <code>cause</code> is not initialized, and may subsequently be78* initialized by a call to the79* {@link Throwable#initCause(java.lang.Throwable)} method.80* <p>81*82* @param failedProperties A Map containing the property values that could not83* be set. The keys in the Map84* contain the names of the client info85* properties that could not be set and86* the values contain one of the reason codes87* defined in <code>ClientInfoStatus</code>88* <p>89* @since 1.690*/91public SQLClientInfoException(Map<String, ClientInfoStatus> failedProperties) {9293this.failedProperties = failedProperties;94}9596/**97* Constructs a <code>SQLClientInfoException</code> object initialized with98* a given <code>cause</code> and <code>failedProperties</code>.99*100* The <code>reason</code> is initialized to <code>null</code> if101* <code>cause==null</code> or to <code>cause.toString()</code> if102* <code>cause!=null</code> and the vendor code is initialized to 0.103*104* <p>105*106* @param failedProperties A Map containing the property values that could not107* be set. The keys in the Map108* contain the names of the client info109* properties that could not be set and110* the values contain one of the reason codes111* defined in <code>ClientInfoStatus</code>112* @param cause the (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating113* the cause is non-existent or unknown.114* <p>115* @since 1.6116*/117public SQLClientInfoException(Map<String, ClientInfoStatus> failedProperties,118Throwable cause) {119120super(cause != null?cause.toString():null);121initCause(cause);122this.failedProperties = failedProperties;123}124125/**126* Constructs a <code>SQLClientInfoException</code> object initialized with a127* given <code>reason</code> and <code>failedProperties</code>.128* The <code>SQLState</code> is initialized129* to <code>null</code> and the vendor code is initialized to 0.130*131* The <code>cause</code> is not initialized, and may subsequently be132* initialized by a call to the133* {@link Throwable#initCause(java.lang.Throwable)} method.134* <p>135*136* @param reason a description of the exception137* @param failedProperties A Map containing the property values that could not138* be set. The keys in the Map139* contain the names of the client info140* properties that could not be set and141* the values contain one of the reason codes142* defined in <code>ClientInfoStatus</code>143* <p>144* @since 1.6145*/146public SQLClientInfoException(String reason,147Map<String, ClientInfoStatus> failedProperties) {148149super(reason);150this.failedProperties = failedProperties;151}152153/**154* Constructs a <code>SQLClientInfoException</code> object initialized with a155* given <code>reason</code>, <code>cause</code> and156* <code>failedProperties</code>.157* The <code>SQLState</code> is initialized158* to <code>null</code> and the vendor code is initialized to 0.159* <p>160*161* @param reason a description of the exception162* @param failedProperties A Map containing the property values that could not163* be set. The keys in the Map164* contain the names of the client info165* properties that could not be set and166* the values contain one of the reason codes167* defined in <code>ClientInfoStatus</code>168* @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 indicating169* the cause is non-existent or unknown.170* <p>171* @since 1.6172*/173public SQLClientInfoException(String reason,174Map<String, ClientInfoStatus> failedProperties,175Throwable cause) {176177super(reason);178initCause(cause);179this.failedProperties = failedProperties;180}181182/**183* Constructs a <code>SQLClientInfoException</code> object initialized with a184* given <code>reason</code>, <code>SQLState</code> and185* <code>failedProperties</code>.186* The <code>cause</code> is not initialized, and may subsequently be187* initialized by a call to the188* {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code189* is initialized to 0.190* <p>191*192* @param reason a description of the exception193* @param SQLState an XOPEN or SQL:2003 code identifying the exception194* @param failedProperties A Map containing the property values that could not195* be set. The keys in the Map196* contain the names of the client info197* properties that could not be set and198* the values contain one of the reason codes199* defined in <code>ClientInfoStatus</code>200* <p>201* @since 1.6202*/203public SQLClientInfoException(String reason,204String SQLState,205Map<String, ClientInfoStatus> failedProperties) {206207super(reason, SQLState);208this.failedProperties = failedProperties;209}210211/**212* Constructs a <code>SQLClientInfoException</code> object initialized with a213* given <code>reason</code>, <code>SQLState</code>, <code>cause</code>214* and <code>failedProperties</code>. The vendor code is initialized to 0.215* <p>216*217* @param reason a description of the exception218* @param SQLState an XOPEN or SQL:2003 code identifying the exception219* @param failedProperties A Map containing the property values that could not220* be set. The keys in the Map221* contain the names of the client info222* properties that could not be set and223* the values contain one of the reason codes224* defined in <code>ClientInfoStatus</code>225* @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 indicating226* the cause is non-existent or unknown.227* <p>228* @since 1.6229*/230public SQLClientInfoException(String reason,231String SQLState,232Map<String, ClientInfoStatus> failedProperties,233Throwable cause) {234235super(reason, SQLState);236initCause(cause);237this.failedProperties = failedProperties;238}239240/**241* Constructs a <code>SQLClientInfoException</code> object initialized with a242* given <code>reason</code>, <code>SQLState</code>,243* <code>vendorCode</code> and <code>failedProperties</code>.244* The <code>cause</code> is not initialized, and may subsequently be245* initialized by a call to the246* {@link Throwable#initCause(java.lang.Throwable)} method.247* <p>248*249* @param reason a description of the exception250* @param SQLState an XOPEN or SQL:2003 code identifying the exception251* @param vendorCode a database vendor-specific exception code252* @param failedProperties A Map containing the property values that could not253* be set. The keys in the Map254* contain the names of the client info255* properties that could not be set and256* the values contain one of the reason codes257* defined in <code>ClientInfoStatus</code>258* <p>259* @since 1.6260*/261public SQLClientInfoException(String reason,262String SQLState,263int vendorCode,264Map<String, ClientInfoStatus> failedProperties) {265266super(reason, SQLState, vendorCode);267this.failedProperties = failedProperties;268}269270/**271* Constructs a <code>SQLClientInfoException</code> object initialized with a272* given <code>reason</code>, <code>SQLState</code>,273* <code>cause</code>, <code>vendorCode</code> and274* <code>failedProperties</code>.275* <p>276*277* @param reason a description of the exception278* @param SQLState an XOPEN or SQL:2003 code identifying the exception279* @param vendorCode a database vendor-specific exception code280* @param failedProperties A Map containing the property values that could not281* be set. The keys in the Map282* contain the names of the client info283* properties that could not be set and284* the values contain one of the reason codes285* defined in <code>ClientInfoStatus</code>286* @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 indicating287* the cause is non-existent or unknown.288* <p>289* @since 1.6290*/291public SQLClientInfoException(String reason,292String SQLState,293int vendorCode,294Map<String, ClientInfoStatus> failedProperties,295Throwable cause) {296297super(reason, SQLState, vendorCode);298initCause(cause);299this.failedProperties = failedProperties;300}301302/**303* Returns the list of client info properties that could not be set. The304* keys in the Map contain the names of the client info305* properties that could not be set and the values contain one of the306* reason codes defined in <code>ClientInfoStatus</code>307* <p>308*309* @return Map list containing the client info properties that could310* not be set311* <p>312* @since 1.6313*/314public Map<String, ClientInfoStatus> getFailedProperties() {315316return this.failedProperties;317}318319private static final long serialVersionUID = -4319604256824655880L;320}321322323