J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2003-2004 Sun Microsystems, Inc. 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. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 24 | */ |
| 25 | |
| 26 | package javax.sql.rowset; |
| 27 | |
| 28 | import java.sql.SQLException; |
| 29 | |
| 30 | /** |
| 31 | * An extension of <code>SQLException</code> that provides information |
| 32 | * about database warnings set on <code>RowSet</code> objects. |
| 33 | * Warnings are silently chained to the object whose method call |
| 34 | * caused it to be reported. |
| 35 | * This class complements the <code>SQLWarning</code> class. |
| 36 | * <P> |
| 37 | * Rowset warnings may be retrieved from <code>JdbcRowSet</code>, |
| 38 | * <code>CachedRowSet</code><sup><font size=-2>TM</font></sup>, |
| 39 | * <code>WebRowSet</code>, <code>FilteredRowSet</code>, or <code>JoinRowSet</code> |
| 40 | * implementations. To retrieve the first warning reported on any |
| 41 | * <code>RowSet</code> |
| 42 | * implementation, use the method <code>getRowSetWarnings</code> defined |
| 43 | * in the <code>JdbcRowSet</code> interface or the <code>CachedRowSet</code> |
| 44 | * interface. To retrieve a warning chained to the first warning, use the |
| 45 | * <code>RowSetWarning</code> method |
| 46 | * <code>getNextWarning</code>. To retrieve subsequent warnings, call |
| 47 | * <code>getNextWarning</code> on each <code>RowSetWarning</code> object that is |
| 48 | * returned. |
| 49 | * <P> |
| 50 | * The inherited methods <code>getMessage</code>, <code>getSQLState</code>, |
| 51 | * and <code>getErrorCode</code> retrieve information contained in a |
| 52 | * <code>RowSetWarning</code> object. |
| 53 | */ |
| 54 | public class RowSetWarning extends SQLException { |
| 55 | |
| 56 | /** |
| 57 | * RowSetWarning object handle. |
| 58 | */ |
| 59 | private RowSetWarning rwarning; |
| 60 | |
| 61 | /** |
| 62 | * Constructs a <code>RowSetWarning</code> object |
| 63 | * with the given value for the reason; SQLState defaults to null, |
| 64 | * and vendorCode defaults to 0. |
| 65 | * |
| 66 | * @param reason a <code>String</code> object giving a description |
| 67 | * of the warning; if the <code>String</code> is <code>null</code>, |
| 68 | * this constructor behaves like the default (zero parameter) |
| 69 | * <code>RowSetWarning</code> constructor |
| 70 | */ |
| 71 | public RowSetWarning(String reason) { |
| 72 | super(reason); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Constructs a default <code>RowSetWarning</code> object. The reason |
| 77 | * defaults to <code>null</code>, SQLState defaults to null and vendorCode |
| 78 | * defaults to 0. |
| 79 | */ |
| 80 | public RowSetWarning() { |
| 81 | super(); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Constructs a <code>RowSetWarning</code> object initialized with the |
| 86 | * given values for the reason and SQLState. The vendor code defaults to 0. |
| 87 | * |
| 88 | * If the <code>reason</code> or <code>SQLState</code> parameters are <code>null</code>, |
| 89 | * this constructor behaves like the default (zero parameter) |
| 90 | * <code>RowSetWarning</code> constructor. |
| 91 | * |
| 92 | * @param reason a <code>String</code> giving a description of the |
| 93 | * warning; |
| 94 | * @param SQLState an XOPEN code identifying the warning; if a non standard |
| 95 | * XOPEN <i>SQLState</i> is supplied, no exception is thrown. |
| 96 | */ |
| 97 | public RowSetWarning(java.lang.String reason, java.lang.String SQLState) { |
| 98 | super(reason, SQLState); |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Constructs a fully specified <code>RowSetWarning</code> object initialized |
| 103 | * with the given values for the reason, SQLState and vendorCode. |
| 104 | * |
| 105 | * If the <code>reason</code>, or the <code>SQLState</code> |
| 106 | * parameters are <code>null</code>, this constructor behaves like the default |
| 107 | * (zero parameter) <code>RowSetWarning</code> constructor. |
| 108 | * |
| 109 | * @param reason a <code>String</code> giving a description of the |
| 110 | * warning; |
| 111 | * @param SQLState an XOPEN code identifying the warning; if a non standard |
| 112 | * XPOEN <i>SQLState</i> is supplied, no exception is thrown. |
| 113 | * @param vendorCode a database vendor-specific warning code |
| 114 | */ |
| 115 | public RowSetWarning(java.lang.String reason, java.lang.String SQLState, int vendorCode) { |
| 116 | super(reason, SQLState, vendorCode); |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Retrieves the warning chained to this <code>RowSetWarning</code> |
| 121 | * object. |
| 122 | * |
| 123 | * @return the <code>RowSetWarning</code> object chained to this one; if no |
| 124 | * <code>RowSetWarning</code> object is chained to this one, |
| 125 | * <code>null</code> is returned (default value) |
| 126 | * @see #setNextWarning |
| 127 | */ |
| 128 | public RowSetWarning getNextWarning() { |
| 129 | return rwarning; |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * Sets <i>warning</i> as the next warning, that is, the warning chained |
| 134 | * to this <code>RowSetWarning</code> object. |
| 135 | * |
| 136 | * @param warning the <code>RowSetWarning</code> object to be set as the |
| 137 | * next warning; if the <code>RowSetWarning</code> is null, this |
| 138 | * represents the finish point in the warning chain |
| 139 | * @see #getNextWarning |
| 140 | */ |
| 141 | public void setNextWarning(RowSetWarning warning) { |
| 142 | rwarning = warning; |
| 143 | } |
| 144 | |
| 145 | static final long serialVersionUID = 6678332766434564774L; |
| 146 | } |