Interface ResultSet (2.42.0)

public interface ResultSet extends StructReader, AutoCloseable

A set of SQL data, generated as the result of an ExecuteQuery request.

This allows access to the data of one row at a time using the methods from the StructReader interface. The rows are read in the order of the query results. To advance to the next row call #next. This returns false once all the rows have been iterated over. The result set is initially positioned before the first row, so #next must be called before reading any data.

#getMetadata() may be called before calling next. It will block until the metadata has been received.

ResultSet implementations may buffer data ahead and/or maintain a persistent streaming connection to the remote service until all data has been returned or the resultSet closed. As such, it is important that all uses of ResultSet either fully consume it (that is, call next() until false is returned or it throws an exception) or explicitly call #close(): failure to do so may result in wasted work or leaked resources.

ResultSet implementations are not required to be thread-safe: the thread that asked for a ResultSet must be the one that interacts with it.

Methods

close()

public abstract void close()

Closes the result set and cancels the underlying request if it is still open. This must always be called when disposing of a ResultSet before #next() has returned false or raised an exception. Calling close() is also allowed if the result set has been fully consumed, so a recommended practice is to unconditionally close the result set once it is done with, typically using a try-with-resources construct.

getMetadata()

public abstract ResultSetMetadata getMetadata()

Returns the ResultSetMetadata for the ResultSet. Blocks until the underlying request receives the metadata.

Returns
Type Description
ResultSetMetadata

next()

public abstract boolean next()

Advances the result set to the next row, returning false if no such row exists. Calls to data access methods will throw an exception after next has returned False.

Returns
Type Description
boolean