home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / Java2 / src / java / sql / SQLWarning.java < prev    next >
Encoding:
Java Source  |  1999-05-28  |  3.2 KB  |  108 lines  |  [TEXT/CWIE]

  1. /*
  2.  * @(#)SQLWarning.java    1.15 98/09/28
  3.  *
  4.  * Copyright 1996-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.sql;
  16.  
  17. /**
  18.  * <P>An exception that provides information on  database access
  19.  * warnings. Warnings are silently chained to the object whose method
  20.  * caused it to be reported.
  21.  *
  22.  * @see Connection#getWarnings
  23.  * @see Statement#getWarnings
  24.  * @see ResultSet#getWarnings 
  25.  */
  26. public class SQLWarning extends SQLException {
  27.  
  28.     /**
  29.      * Constructs a fully-specified <code>SQLWarning</code> object
  30.      * initialized with the given values.
  31.      *
  32.      * @param reason a description of the warning 
  33.      * @param SQLState an XOPEN code identifying the warning
  34.      * @param vendorCode a database vendor-specific warning code
  35.      */
  36.      public SQLWarning(String reason, String SQLstate, int vendorCode) {
  37.     super(reason, SQLstate, vendorCode);
  38.     DriverManager.println("SQLWarning: reason(" + reason + 
  39.                   ") SQLstate(" + SQLstate + 
  40.                   ") vendor code(" + vendorCode + ")");
  41.     }
  42.  
  43.  
  44.     /**
  45.      * Constructs an <code>SQLWarning</code> object
  46.      * with the given reason and SQLState;
  47.      * the vendorCode defaults to 0.
  48.      *
  49.      * @param reason a description of the warning 
  50.      * @param SQLState an XOPEN code identifying the warning
  51.      */
  52.     public SQLWarning(String reason, String SQLstate) {
  53.     super(reason, SQLstate);
  54.     DriverManager.println("SQLWarning: reason(" + reason + 
  55.                   ") SQLState(" + SQLstate + ")");
  56.     }
  57.  
  58.     /**
  59.      * Constructs an <code>SQLWarning</code> object
  60.      * with the given value for a reason; SQLState defaults to
  61.      * null, and vendorCode defaults to 0.
  62.      *
  63.      * @param reason a description of the warning 
  64.      */
  65.     public SQLWarning(String reason) {
  66.     super(reason);
  67.     DriverManager.println("SQLWarning: reason(" + reason + ")");
  68.     }
  69.  
  70.     /**
  71.      * Constructs a default <code>SQLWarning</code> object.
  72.      * The reason defaults to null, SQLState
  73.      * defaults to null, and vendorCode defaults to 0.
  74.      *
  75.      */
  76.     public SQLWarning() {
  77.     super();
  78.     DriverManager.println("SQLWarning: ");
  79.     }
  80.  
  81.  
  82.     /**
  83.      * Retrieves the warning chained to this <code>SQLWarning</code> object.
  84.      *
  85.      * @return the next SQLException in the chain, null if none
  86.      */
  87.     public SQLWarning getNextWarning() {
  88.     try {
  89.         return ((SQLWarning)getNextException());
  90.     } catch (ClassCastException ex) {
  91.         // The chained value isn't a SQLWarning.
  92.         // This is a programming error by whoever added it to
  93.         // the SQLWarning chain.  We throw a Java "Error".
  94.         throw new Error("SQLWarning chain holds value that is not a SQLWarning");
  95.     }
  96.     }
  97.  
  98.     /**
  99.      * Adds an <code>SQLWarning</code> object to the end of the chain.
  100.      *
  101.      * @param w the new end of the <code>SQLException</code> chain
  102.      */
  103.     public void setNextWarning(SQLWarning w) {
  104.     setNextException(w);
  105.     }
  106.  
  107. }
  108.