1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package java.sql; 19 20 import java.util.HashMap; 21 import java.util.Map; 22 23 /** 24 * An exception, which is subclass of SQLException, is thrown when one or more 25 * client info properties could not be set on a Connection. 26 */ 27 public class SQLClientInfoException extends SQLException { 28 private static final long serialVersionUID = -4319604256824655880L; 29 30 final private Map<String, ClientInfoStatus> failedProperties; 31 32 /** 33 * Creates an SQLClientInfoException object. The Reason string is set to 34 * null, the SQLState string is set to null and the Error Code is set to 0. 35 */ 36 public SQLClientInfoException() { 37 this.failedProperties = null; 38 } 39 40 /** 41 * Creates an SQLClientInfoException object. The Reason string is set to the 42 * given reason string, the SQLState string is set to null and the Error 43 * Code is set to 0, and the Map<String,ClientInfoStatus> object is set to 44 * the failed properties. 45 * 46 * @param failedProperties 47 * the Map<String,ClientInfoStatus> object to use as the 48 * property values 49 */ 50 public SQLClientInfoException(Map<String, ClientInfoStatus> failedProperties) { 51 this.failedProperties = new HashMap<String, ClientInfoStatus>(failedProperties); 52 } 53 54 /** 55 * Creates an SQLClientInfoException object. The Reason string is set to the 56 * null if cause == null or cause.toString() if cause!=null, the cause 57 * Throwable object is set to the given cause Throwable object, and the Map<String,ClientInfoStatus> 58 * object is set to the failed properties. 59 * 60 * @param failedProperties 61 * the Map<String,ClientInfoStatus> object to use as the 62 * property values 63 * @param cause 64 * the Throwable object for the underlying reason this 65 * SQLException 66 */ 67 public SQLClientInfoException( 68 Map<String, ClientInfoStatus> failedProperties, Throwable cause) { 69 super(cause); 70 this.failedProperties = new HashMap<String, ClientInfoStatus>(failedProperties); 71 } 72 73 /** 74 * Creates an SQLClientInfoException object. The Reason string is set to 75 * reason, and the Map<String,ClientInfoStatus> object is set to the failed 76 * properties. 77 * 78 * @param reason 79 * the string to use as the Reason string 80 * @param failedProperties 81 * the Map<String,ClientInfoStatus> object to use as the 82 * property values 83 */ 84 public SQLClientInfoException(String reason, 85 Map<String, ClientInfoStatus> failedProperties) { 86 super(reason); 87 this.failedProperties = new HashMap<String, ClientInfoStatus>(failedProperties); 88 } 89 90 /** 91 * Creates an SQLClientInfoException object. The Reason string is set to 92 * reason, the cause Throwable object is set to the given cause Throwable 93 * object, and the Map<String,ClientInfoStatus> object is set to the failed 94 * properties. 95 * 96 * @param reason 97 * the string to use as the Reason string 98 * @param failedProperties 99 * the Map<String,ClientInfoStatus> object to use as the 100 * property values 101 * @param cause 102 * the Throwable object for the underlying reason this 103 * SQLException 104 */ 105 public SQLClientInfoException(String reason, 106 Map<String, ClientInfoStatus> failedProperties, Throwable cause) { 107 super(reason, cause); 108 this.failedProperties = new HashMap<String, ClientInfoStatus>(failedProperties); 109 } 110 111 /** 112 * Creates an SQLClientInfoException object. The Reason string is set to 113 * reason, the SQLState string is set to the sqlState, the Error Code is set 114 * to the vendorCode and the Map<String,ClientInfoStatus> object is set to 115 * the failed properties. 116 * 117 * @param reason 118 * the string to use as the Reason string 119 * @param sqlState 120 * the string to use as the SQLState string 121 * @param vendorCode 122 * the integer value for the error code 123 * @param failedProperties 124 * the Map<String,ClientInfoStatus> object to use as the 125 * property values 126 * 127 */ 128 public SQLClientInfoException(String reason, String sqlState, 129 int vendorCode, Map<String, ClientInfoStatus> failedProperties) { 130 super(reason, sqlState, vendorCode); 131 this.failedProperties = new HashMap<String, ClientInfoStatus>(failedProperties); 132 } 133 134 /** 135 * Creates an SQLClientInfoException object. The Reason string is set to 136 * reason, the SQLState string is set to the sqlState, the Error Code is set 137 * to the vendorCode the cause Throwable object is set to the given cause 138 * Throwable object, and the Map<String,ClientInfoStatus> object is set to 139 * the failed properties. 140 * 141 * @param reason 142 * the string to use as the Reason string 143 * @param sqlState 144 * the string to use as the SQLState string 145 * @param vendorCode 146 * the integer value for the error code 147 * @param failedProperties 148 * the Map<String,ClientInfoStatus> object to use as the 149 * property values 150 * @param cause 151 * the Throwable object for the underlying reason this 152 * SQLException 153 */ 154 public SQLClientInfoException(String reason, String sqlState, 155 int vendorCode, Map<String, ClientInfoStatus> failedProperties, 156 Throwable cause) { 157 super(reason, sqlState, vendorCode, cause); 158 this.failedProperties = new HashMap<String, ClientInfoStatus>(failedProperties); 159 } 160 161 /** 162 * Creates an SQLClientInfoException object. The Reason string is set to 163 * reason, the SQLState string is set to the sqlState, and the Map<String,ClientInfoStatus> 164 * object is set to the failed properties. 165 * 166 * @param reason 167 * the string to use as the Reason string 168 * @param sqlState 169 * the string to use as the SQLState string 170 * @param failedProperties 171 * the Map<String,ClientInfoStatus> object to use as the 172 * property values 173 */ 174 public SQLClientInfoException(String reason, String sqlState, 175 Map<String, ClientInfoStatus> failedProperties) { 176 super(reason, sqlState); 177 this.failedProperties = new HashMap<String, ClientInfoStatus>(failedProperties); 178 } 179 180 /** 181 * Creates an SQLClientInfoException object. The Reason string is set to 182 * reason, the SQLState string is set to the sqlState, the Error Code is set 183 * to the vendorCode, and the Map<String,ClientInfoStatus> object is set to 184 * the failed properties. 185 * 186 * @param reason 187 * the string to use as the Reason string 188 * @param sqlState 189 * the string to use as the SQLState string 190 * @param failedProperties 191 * the Map<String,ClientInfoStatus> object to use as the 192 * property values 193 * @param cause 194 * the Throwable object for the underlying reason this 195 * SQLException 196 */ 197 public SQLClientInfoException(String reason, String sqlState, 198 Map<String, ClientInfoStatus> failedProperties, Throwable cause) { 199 super(reason, sqlState, cause); 200 this.failedProperties = new HashMap<String, ClientInfoStatus>(failedProperties); 201 } 202 203 /** 204 * returns that the client info properties which could not be set 205 * 206 * @return the list of ClientInfoStatus objects indicate client info 207 * properties 208 */ 209 public Map<String, ClientInfoStatus> getFailedProperties() { 210 return failedProperties; 211 } 212 }