Interface ResultSet<T>
- Type Parameters:
T
- A type of the objects contained by this result set (when row set is present). This will be eitherSqlRow
if 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 TypeMethodDescriptionlong
Returns the number of rows affected by the DML statement execution (such as "INSERT", "UPDATE", etc.), or0
if the statement returns nothing (such as "ALTER TABLE", etc.), or-1
if not applicable.void
close()
Invalidates result set and cleans up remote resources.boolean
Indicates whether the query result is a collection of rows.@Nullable ResultSetMetadata
metadata()
Returns metadata for the results if the result contains rows (ifhasRowSet()
returnstrue
).boolean
Indicates 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
null
if 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:
True
if the query returns rows,false
otherwise.
-
affectedRows
long affectedRows()Returns the number of rows affected by the DML statement execution (such as "INSERT", "UPDATE", etc.), or0
if the statement returns nothing (such as "ALTER TABLE", etc.), or-1
if not applicable.Note: If the method returns
-1
, eitherhasRowSet()
orwasApplied()
returnstrue
.- Returns:
- Number of rows affected by the query, or
0
if statement return nothing, or-1
if 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 returnstrue
if the operation was successful, andfalse
if 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:
True
if the query is conditional,false
otherwise.
-
close
void close()Invalidates result set and cleans up remote resources.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCursor<T>
-