public abstract class ResultIterator extends Object implements AutoCloseable
ResultColumn
implementation given the engine in place.| Constructor and Description |
|---|
ResultIterator(PreparedStatement statement)
Creates a new instance of
ResultIterator for PreparedStatement. |
ResultIterator(Statement statement,
String sql)
Creates a new instance of
ResultIterator for regular Statement. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancel()
Attempts to cancel the current query.
|
void |
close()
|
abstract ResultColumn |
createResultColumn(String name,
Object value)
Creates a
ResultColumn for the given engine in place. |
List<String> |
getColumnNames()
Retrieves the column names of the iterator.
|
int |
getCurrentRowCount()
Retrieves the number of rows processed by the iterator so far.
|
protected QueryExceptionHandler |
getQueryExceptionHandler()
Gets the instance of
QueryExceptionHandler to be used in disambiguating SQL exceptions. |
boolean |
isClosed()
Checks if this result iterator is closed.
|
Map<String,ResultColumn> |
next()
Retrieves the next row in the result set.
|
ResultColumn[] |
nextResult()
Retrieves the values of the next row in the result set as an array of objects.
|
public ResultIterator(Statement statement, String sql) throws DatabaseEngineException
ResultIterator for regular Statement.statement - The statement.sql - The SQL sentence.DatabaseEngineException - If a database access error occurs.public ResultIterator(PreparedStatement statement) throws DatabaseEngineException
ResultIterator for PreparedStatement.statement - The prepared statement.DatabaseEngineException - If a database access error occurs.public int getCurrentRowCount()
public Map<String,ResultColumn> next() throws DatabaseEngineException
This method also closes the result set upon the last call on the result set.
If the statement in place is not a PreparedStatement it also closes the statement.
If an exception is thrown the calling thread is responsible for repeating the action in place.
DatabaseEngineException - If a database access error occurs.public ResultColumn[] nextResult() throws DatabaseEngineException
This method provides an optimized version of the next() method with less overhead.
This method also closes the result set upon the last call on the result set.
If the statement in place is not a PreparedStatement it also closes the statement.
If an exception is thrown the calling thread is responsible for repeating the action in place.
DatabaseEngineException - If a database access error occurs.for the names of the columns of this method return.public boolean isClosed()
true if the result set is closed, false otherwise.public List<String> getColumnNames()
public boolean cancel()
Statement.cancel(), which is not guaranteed on all drivers.
A possible use case for this method is to implement a timeout; If that's the case, see also
AbstractDatabaseEngine.iterator(String, int, int) for
an alternative way to accomplish this.
This method is expected to be invoked from a thread distinct of the one that is reading
from the result set.true if the query was cancelled, false otherwise.public void close()
close in interface AutoCloseablepublic abstract ResultColumn createResultColumn(String name, Object value)
ResultColumn for the given engine in place.name - The name of the column.value - The value on the column.protected QueryExceptionHandler getQueryExceptionHandler()
QueryExceptionHandler to be used in disambiguating SQL exceptions.QueryExceptionHandler.Copyright © 2021 Feedzai. All rights reserved.