Index: src/java/org/apache/commons/dbutils/ResultSetIterator.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/dbutils/src/java/org/apache/commons/dbutils/ResultSetIterator.java,v retrieving revision 1.4 diff -u -r1.4 ResultSetIterator.java --- src/java/org/apache/commons/dbutils/ResultSetIterator.java 28 Feb 2004 00:12:23 -0000 1.4 +++ src/java/org/apache/commons/dbutils/ResultSetIterator.java 28 Nov 2004 22:52:51 -0000 @@ -19,6 +19,8 @@ import java.sql.SQLException; import java.util.Iterator; +import org.apache.commons.dbutils.exceptions.SQLRuntimeException; + /** *
* Wraps a ResultSet in an Iterator. This is useful
@@ -57,6 +59,7 @@
* @param convert The processor to use when converting a row into an
* Object[]. Defaults to a
* BasicRowProcessor.
+ * @throws SQLRuntimeException
*/
public ResultSetIterator(ResultSet rs, RowProcessor convert) {
this.rs = rs;
@@ -68,9 +71,7 @@
return !rs.isLast();
} catch (SQLException e) {
- // TODO Logging?
- //e.printStackTrace();
- return false;
+ throw new SQLRuntimeException(e);
}
}
@@ -78,6 +79,7 @@
* Returns the next row as an Object[].
* @return An Object[] with the same number of elements as
* columns in the ResultSet.
+ * @throws SQLRuntimeException
* @see java.util.Iterator#next()
*/
public Object next() {
@@ -86,14 +88,13 @@
return this.convert.toArray(rs);
} catch (SQLException e) {
- // TODO Logging?
- //e.printStackTrace();
- return null;
+ throw new SQLRuntimeException(e);
}
}
/**
* Deletes the current row from the ResultSet.
+ * @throws SQLRuntimeException
* @see java.util.Iterator#remove()
*/
public void remove() {
@@ -101,8 +102,7 @@
this.rs.deleteRow();
} catch (SQLException e) {
- // TODO Logging?
- //e.printStackTrace();
+ throw new SQLRuntimeException(e);
}
}
Index: src/java/org/apache/commons/dbutils/exceptions/SQLRuntimeException.java
===================================================================
RCS file: src/java/org/apache/commons/dbutils/exceptions/SQLRuntimeException.java
diff -N src/java/org/apache/commons/dbutils/exceptions/SQLRuntimeException.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/java/org/apache/commons/dbutils/exceptions/SQLRuntimeException.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2002-2004 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils.exceptions;
+
+/**
+ * Special runtime exception for wrapping SqlExceptions in methods
+ * with signatures that do not allow throwing them.
+ */
+public class SQLRuntimeException extends RuntimeException {
+
+ /**
+ * Exception to be used if no message or cause are avaiable.
+ */
+ public SQLRuntimeException() {
+ super();
+ }
+
+ /**
+ * @param message The message of the exception.
+ */
+ public SQLRuntimeException(String message) {
+ super(message);
+ }
+
+ /**
+ * @param message The message of the exception.
+ * @param cause The Throwable which caused the exception.
+ */
+ public SQLRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * @param cause The Throwable which caused the exception.
+ */
+ public SQLRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+}