home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / SQLWarning.java < prev    next >
Text File  |  1997-05-20  |  3KB  |  112 lines

  1. /*
  2.  * @(#)SQLWarning.java    1.5 96/11/23
  3.  * 
  4.  * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.1_beta
  20.  * 
  21.  */
  22.  
  23. package java.sql;
  24.  
  25. /**
  26.  * <P>The SQLWarning class provides information on a database access
  27.  * warnings. Warnings are silently chained to the object whose method
  28.  * caused it to be reported.
  29.  *
  30.  * @see Connection#getWarnings
  31.  * @see Statement#getWarnings
  32.  * @see ResultSet#getWarnings 
  33.  */
  34. public class SQLWarning extends SQLException {
  35.  
  36.     /**
  37.      * Construct a fully specified SQLWarning.
  38.      *
  39.      * @param reason a description of the warning 
  40.      * @param SQLState an XOPEN code identifying the warning
  41.      * @param vendorCode a database vendor specific warning code
  42.      */
  43.      public SQLWarning(String reason, String SQLstate, int vendorCode) {
  44.     super(reason, SQLstate, vendorCode);
  45.     DriverManager.println("SQLWarning: reason(" + reason + 
  46.                   ") SQLstate(" + SQLstate + 
  47.                   ") vendor code(" + vendorCode + ")");
  48.     }
  49.  
  50.  
  51.     /**
  52.      * Construct an SQLWarning with a reason and SQLState;
  53.      * vendorCode defaults to 0.
  54.      *
  55.      * @param reason a description of the warning 
  56.      * @param SQLState an XOPEN code identifying the warning
  57.      */
  58.     public SQLWarning(String reason, String SQLstate) {
  59.     super(reason, SQLstate);
  60.     DriverManager.println("SQLWarning: reason(" + reason + 
  61.                   ") SQLState(" + SQLstate + ")");
  62.     }
  63.  
  64.     /**
  65.      * Construct an SQLWarning with a reason; SQLState defaults to
  66.      * null and vendorCode defaults to 0.
  67.      *
  68.      * @param reason a description of the warning 
  69.      */
  70.     public SQLWarning(String reason) {
  71.     super(reason);
  72.     DriverManager.println("SQLWarning: reason(" + reason + ")");
  73.     }
  74.  
  75.     /**
  76.      * Construct an SQLWarning ; reason defaults to null, SQLState
  77.      * defaults to null and vendorCode defaults to 0.
  78.      *
  79.      */
  80.     public SQLWarning() {
  81.     super();
  82.     DriverManager.println("SQLWarning: ");
  83.     }
  84.  
  85.  
  86.     /**
  87.      * Get the warning chained to this one
  88.      *
  89.      * @return the next SQLException in the chain, null if none
  90.      */
  91.     public SQLWarning getNextWarning() {
  92.     try {
  93.         return ((SQLWarning)getNextException());
  94.     } catch (ClassCastException ex) {
  95.         // The chained value isn't a SQLWarning.
  96.         // This is a programming error by whoever added it to
  97.         // the SQLWarning chain.  We throw a Java "Error".
  98.         throw new Error("SQLWarning chain holds value that is not a SQLWarning");
  99.     }
  100.     }
  101.  
  102.     /**
  103.      * Add an SQLWarning to the end of the chain.
  104.      *
  105.      * @param w the new end of the SQLException chain
  106.      */
  107.     public void setNextWarning(SQLWarning w) {
  108.     setNextException(w);
  109.     }
  110.  
  111. }
  112.