1 61 62 package org.apache.commons.dbutils; 63 64 import java.sql.ResultSet ; 65 import java.sql.SQLException ; 66 import java.util.Iterator ; 67 68 83 public class ResultSetIterator implements Iterator { 84 85 88 private ResultSet rs = null; 89 90 93 private RowProcessor convert = BasicRowProcessor.instance(); 94 95 99 public ResultSetIterator(ResultSet rs) { 100 this.rs = rs; 101 } 102 103 110 public ResultSetIterator(ResultSet rs, RowProcessor convert) { 111 this.rs = rs; 112 this.convert = convert; 113 } 114 115 public boolean hasNext() { 116 try { 117 return !rs.isLast(); 118 119 } catch (SQLException e) { 120 return false; 123 } 124 } 125 126 132 public Object next() { 133 try { 134 rs.next(); 135 return this.convert.toArray(rs); 136 137 } catch (SQLException e) { 138 return null; 141 } 142 } 143 144 148 public void remove() { 149 try { 150 this.rs.deleteRow(); 151 152 } catch (SQLException e) { 153 } 156 } 157 158 } 159 | Popular Tags |