Java Reference
In-Depth Information
} catch (Exception ignore) {}
}
}
/**
* Returns {@code true} if the iteration has more elements.
* (In other words, returns {@code true} if {@link #next} would
* return an element rather than throwing an exception.)
*
* @return {@code true} if the iteration has more elements
*/
@Override
public boolean hasNext() {
try {
if (hasNext == null) {
hasNext = !resultSet.isClosed() && resultSet.next();
}
} catch (SQLException sqle) {
throw new RuntimeException(
"Could not determine if we have a next element", sqle
);
}
if (!hasNext) doClose();
return hasNext;
}
/**
* Returns the next element in the iteration.
*
* @return the next element in the iteration
* @throws java.util.NoSuchElementException if the iteration has no
* more elements
*/
@Override
public RESULT_T next() {
if (!hasNext()) {
throw new NoSuchElementException("No elements remaining");
}
try {
return processRow(resultSet);
} catch (SQLException sqle) {
throw new RuntimeException("Error while processing elements", sqle);
} finally {
hasNext = null;
}
}
}
Search WWH ::




Custom Search