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