Interface ResultSet<T>
- Type Parameters:
T- A type of the objects contained by this result set (when row set is present). This will be eitherSqlRowif no explicit mapper is provided or a particular type defined by supplied mapper.
- All Superinterfaces:
AutoCloseable,Cursor<T>,Iterator<T>
SqlRow.
All rows in the result set have the same structure described in ResultSetMetadata.
ResultSet must be closed after usage to free resources.
The class and its methods are not thread-safe. If more than one thread use the result set object, use external synchronization on iterator methods.
Note: Only one of following is possible: hasRowSet() returns true, or wasApplied() returns
true, or affectedRows() return zero or higher value.
-
Method Summary
Modifier and TypeMethodDescriptionlongReturns the number of rows affected by the DML statement execution (such as "INSERT", "UPDATE", etc.), or0if the statement returns nothing (such as "ALTER TABLE", etc.), or-1if not applicable.voidclose()Invalidates result set and cleans up remote resources.booleanIndicates whether the query result is a collection of rows.@Nullable ResultSetMetadatametadata()Returns metadata for the results if the result contains rows (ifhasRowSet()returnstrue).booleanIndicates whether the query that had produced the result was a conditional query.Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
Method Details
-
metadata
Returns metadata for the results if the result contains rows (ifhasRowSet()returnstrue).- Returns:
- ResultSet metadata or
nullif not applicable.
-
hasRowSet
boolean hasRowSet()Indicates whether the query result is a collection of rows.Note: If the method returns
false, callingIterator.hasNext(),Iterator.next()will fail, and eitheraffectedRows()returns the number of the affected rows orwasApplied()returnstrue.- Returns:
Trueif the query returns rows,falseotherwise.
-
affectedRows
long affectedRows()Returns the number of rows affected by the DML statement execution (such as "INSERT", "UPDATE", etc.), or0if the statement returns nothing (such as "ALTER TABLE", etc.), or-1if not applicable.Note: If the method returns
-1, eitherhasRowSet()orwasApplied()returnstrue.- Returns:
- Number of rows affected by the query, or
0if statement return nothing, or-1if not applicable.
-
wasApplied
boolean wasApplied()Indicates whether the query that had produced the result was a conditional query. E.g., for query "Create table if not exists", the method returnstrueif the operation was successful, andfalseif the operation was ignored because the table already existed.Note: If the method returns
false, eitheraffectedRows()returns the number the affected rows orhasRowSet()returnstrue.- Returns:
Trueif the query is conditional,falseotherwise.
-
close
void close()Invalidates result set and cleans up remote resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCursor<T>
-