Path: blob/master/src/java.sql.rowset/share/classes/javax/sql/rowset/RowSetWarning.java
40948 views
/*1* Copyright (c) 2003, 2014, 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*/2425package javax.sql.rowset;2627import java.sql.SQLException;2829/**30* An extension of <code>SQLException</code> that provides information31* about database warnings set on <code>RowSet</code> objects.32* Warnings are silently chained to the object whose method call33* caused it to be reported.34* This class complements the <code>SQLWarning</code> class.35* <P>36* Rowset warnings may be retrieved from <code>JdbcRowSet</code>,37* <code>CachedRowSet</code>,38* <code>WebRowSet</code>, <code>FilteredRowSet</code>, or <code>JoinRowSet</code>39* implementations. To retrieve the first warning reported on any40* <code>RowSet</code>41* implementation, use the method <code>getRowSetWarnings</code> defined42* in the <code>JdbcRowSet</code> interface or the <code>CachedRowSet</code>43* interface. To retrieve a warning chained to the first warning, use the44* <code>RowSetWarning</code> method45* <code>getNextWarning</code>. To retrieve subsequent warnings, call46* <code>getNextWarning</code> on each <code>RowSetWarning</code> object that is47* returned.48* <P>49* The inherited methods <code>getMessage</code>, <code>getSQLState</code>,50* and <code>getErrorCode</code> retrieve information contained in a51* <code>RowSetWarning</code> object.52*53* @since 1.554*/55public class RowSetWarning extends SQLException {5657/**58* Constructs a <code>RowSetWarning</code> object59* with the given value for the reason; SQLState defaults to null,60* and vendorCode defaults to 0.61*62* @param reason a <code>String</code> object giving a description63* of the warning; if the <code>String</code> is <code>null</code>,64* this constructor behaves like the default (zero parameter)65* <code>RowSetWarning</code> constructor66*/67public RowSetWarning(String reason) {68super(reason);69}7071/**72* Constructs a default <code>RowSetWarning</code> object. The reason73* defaults to <code>null</code>, SQLState defaults to null and vendorCode74* defaults to 0.75*/76public RowSetWarning() {77super();78}7980/**81* Constructs a <code>RowSetWarning</code> object initialized with the82* given values for the reason and SQLState. The vendor code defaults to 0.83*84* If the <code>reason</code> or <code>SQLState</code> parameters are <code>null</code>,85* this constructor behaves like the default (zero parameter)86* <code>RowSetWarning</code> constructor.87*88* @param reason a <code>String</code> giving a description of the89* warning;90* @param SQLState an XOPEN code identifying the warning; if a non standard91* XOPEN <i>SQLState</i> is supplied, no exception is thrown.92*/93public RowSetWarning(java.lang.String reason, java.lang.String SQLState) {94super(reason, SQLState);95}9697/**98* Constructs a fully specified <code>RowSetWarning</code> object initialized99* with the given values for the reason, SQLState and vendorCode.100*101* If the <code>reason</code>, or the <code>SQLState</code>102* parameters are <code>null</code>, this constructor behaves like the default103* (zero parameter) <code>RowSetWarning</code> constructor.104*105* @param reason a <code>String</code> giving a description of the106* warning;107* @param SQLState an XOPEN code identifying the warning; if a non standard108* XOPEN <i>SQLState</i> is supplied, no exception is thrown.109* @param vendorCode a database vendor-specific warning code110*/111public RowSetWarning(java.lang.String reason, java.lang.String SQLState, int vendorCode) {112super(reason, SQLState, vendorCode);113}114115/**116* Retrieves the warning chained to this <code>RowSetWarning</code>117* object.118*119* @return the <code>RowSetWarning</code> object chained to this one; if no120* <code>RowSetWarning</code> object is chained to this one,121* <code>null</code> is returned (default value)122* @see #setNextWarning123*/124public RowSetWarning getNextWarning() {125SQLException warning = getNextException();126if ( warning == null || warning instanceof RowSetWarning) {127return (RowSetWarning)warning;128} else {129// The chained value isn't a RowSetWarning.130// This is a programming error by whoever added it to131// the RowSetWarning chain. We throw a Java "Error".132throw new Error("RowSetWarning chain holds value that is not a RowSetWarning: ");133}134}135136/**137* Sets <i>warning</i> as the next warning, that is, the warning chained138* to this <code>RowSetWarning</code> object.139*140* @param warning the <code>RowSetWarning</code> object to be set as the141* next warning; if the <code>RowSetWarning</code> is null, this142* represents the finish point in the warning chain143* @see #getNextWarning144*/145public void setNextWarning(RowSetWarning warning) {146setNextException(warning);147}148149static final long serialVersionUID = 6678332766434564774L;150}151152153