]> granicus.if.org Git - postgresql/commitdiff
Patch by Nicolas Verger to correctly propogate SQLWarning to the Statement and ResultSet
authorDave Cramer <davec@fastcrypt.com>
Tue, 5 Mar 2002 18:02:44 +0000 (18:02 +0000)
committerDave Cramer <davec@fastcrypt.com>
Tue, 5 Mar 2002 18:02:44 +0000 (18:02 +0000)
src/interfaces/jdbc/org/postgresql/ResultSet.java
src/interfaces/jdbc/org/postgresql/Statement.java

index a9da22d4f46474e2c858e0951dfe6037842f1662..768a489e6f31d202627f92dbabaa6ec6ee0b7e8b 100644 (file)
@@ -223,5 +223,37 @@ public abstract class ResultSet
 
                return s;
        }
+
+       /**
+        * The first warning reported by calls on this ResultSet is
+        * returned.  Subsequent ResultSet warnings will be chained
+        * to this SQLWarning.
+        *
+        * <p>The warning chain is automatically cleared each time a new
+        * row is read.
+        *
+        * <p><B>Note:</B> This warning chain only covers warnings caused by
+        * ResultSet methods.  Any warnings caused by statement methods
+        * (such as reading OUT parameters) will be chained on the
+        * Statement object.
+        *
+        * @return the first SQLWarning or null;
+        * @exception SQLException if a database access error occurs.
+        */
+       public SQLWarning getWarnings() throws SQLException
+       {
+               return warnings;
+       }
+
+        /**
+        * Add a warning chain to the current warning chain
+        * @param warnings warnings to add
+        */    
+        public void addWarnings(SQLWarning warnings) {
+           if ( this.warnings != null )
+               this.warnings.setNextWarning(warnings);
+           else
+               this.warnings = warnings;
+       }
 }
 
index dbd061bfd3910f6094872080ab330efa7c2795ba..ea2cc0d0c33094ca88ab5f7d2750e86e41180fdb 100644 (file)
@@ -110,6 +110,18 @@ public abstract class Statement
                timeout = seconds;
        }
 
+       /**
+        * This adds a warning to the warning chain.
+        * @param msg message to add
+        */
+       public void addWarning(String msg)
+        {
+           if (warnings != null)
+               warnings.setNextWarning(new SQLWarning(msg));
+           else
+               warnings = new SQLWarning(msg);
+       }
+
        /*
         * The first warning reported by calls on this Statement is
         * returned.  A Statement's execute methods clear its SQLWarning