public interface SqlResult extends Iterable<SqlRow>, AutoCloseable
iterator()
to iterate over the rows.
close()
to release the resources associated with the
result.
Code example:
try (SqlResult result = hazelcastInstance.getSql().execute("SELECT ...")) { for (SqlRow row : result) { // Process the row. } }
long updated = hazelcastInstance.getSql().execute("UPDATE ...").updateCount();You don't need to call
close()
in this case.Modifier and Type | Method and Description |
---|---|
void |
close()
Release the resources associated with the query result.
|
SqlRowMetadata |
getRowMetadata()
Gets the row metadata.
|
default boolean |
isRowSet()
Return whether this result has rows to iterate using the
iterator() method. |
Iterator<SqlRow> |
iterator()
Returns the iterator over the result rows.
|
long |
updateCount()
Returns the number of rows updated by the statement or -1 if this result
is a row set.
|
forEach, spliterator
default boolean isRowSet()
iterator()
method.@Nonnull SqlRowMetadata getRowMetadata()
IllegalStateException
- if the result doesn't have rows, but
only an update count@Nonnull Iterator<SqlRow> iterator()
The iterator may be requested only once.
iterator
in interface Iterable<SqlRow>
IllegalStateException
- if the method is invoked more than once or
if this result doesn't have rowsHazelcastSqlException
- in case of an SQL-related error conditionlong updateCount()
void close()
The query engine delivers the rows asynchronously. The query may become inactive even before all rows are consumed. The invocation of this command will cancel the execution of the query on all members if the query is still active. Otherwise it is no-op. For a result with an update count it is always no-op.
close
in interface AutoCloseable
Copyright © 2023 Hazelcast, Inc.. All rights reserved.