public class ResultIterator<T> extends PeekIterator<T>
// We need this class to define how to construct an Employer from a table row
public static class EmployerWrapper implements ResultWrapper<Employer> {
// Wraps the current row in a ResultSet into an Employer
public Employer wrap(ResultSet r) {
return(new Employer(r.getString(1),r.getDouble(2));
}
}
Database d=new OracleDatabase("scott","tiger");
for(Employer e : d.query("SELECT * FROM employers WHERE salary>1000",
new EmployerConstructor())) {
System.out.println(e);
}
| Modifier and Type | Class and Description |
|---|---|
static interface |
ResultIterator.ResultWrapper<T>
Wraps the current row in a ResultSet into a T
|
PeekIterator.ElementaryPeekIterator<T>, PeekIterator.SimplePeekIterator<T>| Modifier and Type | Field and Description |
|---|---|
static ResultIterator.ResultWrapper<Boolean> |
BooleanWrapper
ResultWrapper for a single Boolean column
|
protected ResultIterator.ResultWrapper<T> |
constructor
Holds the constructor to be used for each row
|
static ResultIterator.ResultWrapper<Double[]> |
DoublesWrapper
ResultWrapper for several Doubles.
|
static ResultIterator.ResultWrapper<Double> |
DoubleWrapper
ResultWrapper for a single Double column.
|
static ResultIterator.ResultWrapper<Integer[]> |
IntegersWrapper
ResultWrapper for several Integers.
|
static ResultIterator.ResultWrapper<Integer> |
IntegerWrapper
ResultWrapper for a single Integer column
|
static ResultIterator.ResultWrapper<Long> |
LongWrapper
ResultWrapper for a single Long column.
|
protected ResultSet |
resultSet
Holds the resultSet
|
static ResultIterator.ResultWrapper<String[]> |
StringsWrapper
ResultWrapper for String columns
|
static ResultIterator.ResultWrapper<String> |
StringWrapper
ResultWrapper for a single String column
|
closed, EMPTY, fetchedNextValue, next| Modifier | Constructor and Description |
|---|---|
protected |
ResultIterator()
For subclasses
|
|
ResultIterator(ResultSet s,
ResultIterator.ResultWrapper<T> cons)
Creates a ResultIterator for a ResultSet
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the resultset and the underlying statement
|
void |
finalize()
Closes the resultset
|
T |
internalNext()
Returns the next or NULL if no next element is available
|
asList, asList, asSet, asSet, asSet, emptyIterator, hasNext, internalSilentNext, iterator, list, list, main, next, nextOrNull, numElements, numElements, peek, remove, toString, toString, toStringclone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitforEachRemainingforEach, spliteratorprotected ResultSet resultSet
protected ResultIterator.ResultWrapper<T> constructor
public static final ResultIterator.ResultWrapper<Boolean> BooleanWrapper
public static final ResultIterator.ResultWrapper<String> StringWrapper
public static final ResultIterator.ResultWrapper<String[]> StringsWrapper
public static final ResultIterator.ResultWrapper<Long> LongWrapper
public static final ResultIterator.ResultWrapper<Double> DoubleWrapper
public static final ResultIterator.ResultWrapper<Double[]> DoublesWrapper
public static final ResultIterator.ResultWrapper<Integer> IntegerWrapper
public static final ResultIterator.ResultWrapper<Integer[]> IntegersWrapper
public ResultIterator(ResultSet s, ResultIterator.ResultWrapper<T> cons)
protected ResultIterator()
public T internalNext() throws Exception
PeekIteratorinternalNext in class PeekIterator<T>Exceptionpublic void close()
close in interface Closeableclose in interface AutoCloseableclose in class PeekIterator<T>Copyright © 2018. All rights reserved.