public final class Result
extends java.lang.Object
implements java.lang.AutoCloseable
Executing a query returns a result (see Connection.executeQuery(String)
). The rows of a result can be
iterated via nextRow()
. The value of each column can be accessed via a type-specific getter such as
getInt(int)
.
This is an AutoCloseable
class since it maintains native resources. The close()
method must always be called when the result is no longer needed. The best way to guarantee this is to use a
try-with-resources block.
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this result object, relinquishing the underlying native handles.
|
java.util.OptionalLong |
getAffectedRowCount()
Gets the number of rows affected by the SQL command.
|
java.math.BigDecimal |
getBigDecimal(int position)
Gets the value of column `position` for the current row as BigDecimal.
|
boolean |
getBool(int position)
Gets the value of column `position` for the current row as boolean.
|
byte[] |
getByteArray(int position)
Gets the value of column `position` for the current row as byte array.
|
Connection |
getConnection()
Gets the connection of the SQL statement that yielded this result.
|
double |
getDouble(int position)
Gets the value of column `position` for the current row as double.
|
int |
getInt(int position)
Gets the value of column `position` for the current row as integer.
|
Interval |
getInterval(int position)
Gets the value of column `position` for the current row as interval.
|
java.time.LocalDate |
getLocalDate(int position)
Gets the value of column `position` for the current row as local date.
|
java.time.LocalDateTime |
getLocalDateTime(int position)
Gets the value of column `position` for the current row as local date time.
|
java.time.LocalTime |
getLocalTime(int position)
Gets the value of column `position` for the current row as local time.
|
long |
getLong(int position)
Gets the value of column `position` for the current row as long.
|
java.lang.Object |
getObject(int position)
Gets the value of column `position` for the current row as Object.
|
java.time.OffsetDateTime |
getOffsetDateTime(int position)
Gets the value of column `position` for the current row as an offset date time in UTC.
|
byte[] |
getRaw(int position)
Gets the value of column `position` for the current row as a raw value.
|
ResultSchema |
getSchema()
Gets the schema of the result.
|
short |
getShort(int position)
Gets the value of column `position` for the current row as short.
|
java.lang.String |
getString(int position)
Gets the value of column `position` for the current row as string.
|
java.time.ZonedDateTime |
getZonedDateTime(int position)
Gets the value of column `position` for the current row as a zoned date time in UTC.
|
boolean |
isNull(int position)
Returns whether the value of column `position` is null for the current row.
|
boolean |
isOpen()
Returns whether the result is open.
|
boolean |
nextRow()
Gets the next row of the result.
|
public void close()
close
in interface java.lang.AutoCloseable
public boolean isOpen()
public ResultSchema getSchema()
public java.util.OptionalLong getAffectedRowCount()
public Connection getConnection()
public boolean nextRow()
public boolean isNull(int position)
position
- The column position.public short getShort(int position)
position
- The column for which to retrieve the value.HyperException
- If the column has an incompatible type.public int getInt(int position)
position
- The column for which to retrieve the value.HyperException
- If the column has an incompatible type.public long getLong(int position)
position
- The column for which to retrieve the value.HyperException
- If the column has an incompatible type.public double getDouble(int position)
position
- The column for which to retrieve the value.HyperException
- If the column has an incompatible type.public java.lang.String getString(int position)
position
- The column for which to retrieve the value.HyperException
- If the column has an incompatible type.public boolean getBool(int position)
position
- The column for which to retrieve the value.HyperException
- If the column has an incompatible type.public java.math.BigDecimal getBigDecimal(int position)
position
- The column for which to retrieve the value.HyperException
- If the column has an incompatible type.public byte[] getByteArray(int position)
position
- The column for which to retrieve the value.HyperException
- If the column has an incompatible type.public java.time.LocalDate getLocalDate(int position)
position
- The column for which to retrieve the value.HyperException
- If the column has an incompatible type.public Interval getInterval(int position)
position
- The column for which to retrieve the value.HyperException
- If the column has an incompatible type.public java.time.LocalTime getLocalTime(int position)
position
- The column for which to retrieve the value.HyperException
- If the column has an incompatible type.public java.time.LocalDateTime getLocalDateTime(int position)
position
- The column for which to retrieve the value.HyperException
- If the column has an incompatible type.public java.time.ZonedDateTime getZonedDateTime(int position)
position
- The column for which to retrieve the value.HyperException
- If the column has an incompatible type.public java.time.OffsetDateTime getOffsetDateTime(int position)
position
- The column for which to retrieve the value.HyperException
- If the column has an incompatible type.public byte[] getRaw(int position)
position
- The column for which to retrieve the value.public java.lang.Object getObject(int position)
position
- The column for which to retrieve the value.HyperException
- If the column has an unsupported type.