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 row metadata.
|
boolean |
isUpdateCount()
If this result represents a row set, this method returns
false . |
Iterator<SqlRow> |
iterator()
Returns the iterator over the result rows.
|
long |
updateCount()
Returns the number of rows updated by the statement.
|
forEach, spliterator
boolean isUpdateCount()
false
.
If this result represents an update count (such as for a DML query), it
returns true
.false
for a rows result and true
for an update
count result@Nonnull SqlRowMetadata getRowMetadata()
IllegalStateException
- if this result doesn't have rows (i.e.
when isUpdateCount()
returns true
)@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 rows (i.e. when isUpdateCount()
returns true
)HazelcastSqlException
- in case of an SQL-related error conditionlong updateCount()
IllegalStateException
- if this result doesn't represent an update
count (i.e. when isUpdateCount()
returns false
)void close()
false
, that is when it's a result with rows, otherwise it's a no-op.
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.
close
in interface AutoCloseable
Copyright © 2020 Hazelcast, Inc.. All rights reserved.