commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgra...@apache.org
Subject svn commit: r154450 - in jakarta/commons/proper/dbutils/trunk: project.xml src/java/org/apache/commons/dbutils/ResultSetIterator.java xdocs/changes.xml
Date Sat, 19 Feb 2005 20:46:48 GMT
Author: dgraham
Date: Sat Feb 19 12:46:46 2005
New Revision: 154450

URL: http://svn.apache.org/viewcvs?view=rev&rev=154450
Log:
Rethrow SQLExceptions from ResultSetIterator as RuntimeExceptions.
PR: 32120

Modified:
    jakarta/commons/proper/dbutils/trunk/project.xml
    jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/ResultSetIterator.java
    jakarta/commons/proper/dbutils/trunk/xdocs/changes.xml

Modified: jakarta/commons/proper/dbutils/trunk/project.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/dbutils/trunk/project.xml?view=diff&r1=154449&r2=154450
==============================================================================
--- jakarta/commons/proper/dbutils/trunk/project.xml (original)
+++ jakarta/commons/proper/dbutils/trunk/project.xml Sat Feb 19 12:46:46 2005
@@ -127,6 +127,15 @@
       </roles>
     </contributor>
     <contributor>
+      <name>Stefan Fleiter</name>
+      <id></id>
+      <email>stefan.fleiter@web.de</email>
+      <organization></organization>
+      <roles>
+        <role>Java Developer</role>
+      </roles>
+    </contributor>
+    <contributor>
       <name>Adkins Kendall</name>
       <id></id>
       <email></email>

Modified: jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/ResultSetIterator.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/ResultSetIterator.java?view=diff&r1=154449&r2=154450
==============================================================================
--- jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/ResultSetIterator.java
(original)
+++ jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/ResultSetIterator.java
Sat Feb 19 12:46:46 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2004 The Apache Software Foundation
+ * Copyright 2002-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.commons.dbutils;
 
 import java.sql.ResultSet;
@@ -63,10 +64,15 @@
         this.convert = convert;
     }
 
+    /**
+     * Returns true if there are more rows in the ResultSet.
+     * @throws RuntimeException if an SQLException occurs.
+     */
     public boolean hasNext() {
         try {
             return !rs.isLast();
         } catch (SQLException e) {
+            rethrow(e);
             return false;
         }
     }
@@ -76,12 +82,14 @@
      * @return An <code>Object[]</code> with the same number of elements as
      * columns in the <code>ResultSet</code>. 
      * @see java.util.Iterator#next()
+     * @throws RuntimeException if an SQLException occurs.
      */
     public Object next() {
         try {
             rs.next();
             return this.convert.toArray(rs);
         } catch (SQLException e) {
+            rethrow(e);
             return null;
         }
     }
@@ -89,12 +97,23 @@
     /**
      * Deletes the current row from the <code>ResultSet</code>.
      * @see java.util.Iterator#remove()
+     * @throws RuntimeException if an SQLException occurs.
      */
     public void remove() {
         try {
             this.rs.deleteRow();
         } catch (SQLException e) {
+            rethrow(e);
         }
     }
 
-}
+    /**
+     * Rethrow the SQLException as a RuntimeException.  This implementation
+     * creates a new RuntimeException with the SQLException's error message.
+     * @since DbUtils 1.1
+     */
+    protected void rethrow(SQLException e) {
+        throw new RuntimeException(e.getMessage());
+    }
+
+}
\ No newline at end of file

Modified: jakarta/commons/proper/dbutils/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/dbutils/trunk/xdocs/changes.xml?view=diff&r1=154449&r2=154450
==============================================================================
--- jakarta/commons/proper/dbutils/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/dbutils/trunk/xdocs/changes.xml Sat Feb 19 12:46:46 2005
@@ -39,6 +39,10 @@
   <body>
 
     <release version="1.1-dev" date="in CVS">
+      <action dev="dgraham" type="add">
+        Added protected ResultSetIterator.rethrow() method to wrap SQLExceptions in 
+        RuntimeExceptions.  PR: 32120
+      </action>
       <action dev="dgraham" type="update">
         Added SQLState and error code to rethrown SQLExceptions.  PR: 33614
       </action>



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message