Package com.tableau.hyperapi
Class Result
- java.lang.Object
-
- com.tableau.hyperapi.Result
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public final class Result extends java.lang.Object implements java.lang.AutoCloseable
A query result.Executing a query returns a result (see
Connection.executeQuery(String)
). The rows of a result can be iterated vianextRow()
. The value of each column can be accessed via a type-specific getter such asgetInt(int)
.This is an
AutoCloseable
class since it maintains native resources. Theclose()
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.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.float
getFloat(int position)
Gets the value of column `position` for the current row as float.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.
-
-
-
Method Detail
-
close
public void close()
Closes this result object, relinquishing the underlying native handles.- Specified by:
close
in interfacejava.lang.AutoCloseable
-
isOpen
public boolean isOpen()
Returns whether the result is open.- Returns:
- Whether the result is open.
-
getSchema
public ResultSchema getSchema()
Gets the schema of the result.- Returns:
- The schema of the result.
-
getAffectedRowCount
public java.util.OptionalLong getAffectedRowCount()
Gets the number of rows affected by the SQL command.- Returns:
- The modified row count of the SQL command if it has one.
-
getConnection
public Connection getConnection()
Gets the connection of the SQL statement that yielded this result.- Returns:
- The connection.
-
nextRow
public boolean nextRow()
Gets the next row of the result. Returns false if there is no next row.- Returns:
- Whether there is a next row.
-
isNull
public boolean isNull(int position)
Returns whether the value of column `position` is null for the current row.- Parameters:
position
- The column position.- Returns:
- Whether the value is null.
-
getShort
public short getShort(int position)
Gets the value of column `position` for the current row as short. Can be used for columns with the SQL type "SMALLINT".- Parameters:
position
- The column for which to retrieve the value.- Returns:
- The value.
- Throws:
HyperException
- If the column has an incompatible type.
-
getInt
public int getInt(int position)
Gets the value of column `position` for the current row as integer. Can be used for columns with SQL types: "INTEGER", "OID" and "SMALLINT.- Parameters:
position
- The column for which to retrieve the value.- Returns:
- The value.
- Throws:
HyperException
- If the column has an incompatible type.
-
getLong
public long getLong(int position)
Gets the value of column `position` for the current row as long. Can be used for columns with SQL types: "BIGINTEGER", "INTEGER", "NUMERIC" and "SMALLINT.- Parameters:
position
- The column for which to retrieve the value.- Returns:
- The value.
- Throws:
HyperException
- If the column has an incompatible type.
-
getFloat
public float getFloat(int position)
Gets the value of column `position` for the current row as float. Can be used for columns with SQL types: "REAL", "DOUBLE PRECISION", "BIGINTEGER", "INTEGER", "NUMERIC" and "SMALLINT.- Parameters:
position
- The column for which to retrieve the value.- Returns:
- The value.
- Throws:
HyperException
- If the column has an incompatible type.
-
getDouble
public double getDouble(int position)
Gets the value of column `position` for the current row as double. Can be used for columns with SQL types: "REAL", "DOUBLE PRECISION", "BIGINTEGER", "INTEGER", "NUMERIC" and "SMALLINT.- Parameters:
position
- The column for which to retrieve the value.- Returns:
- The value.
- Throws:
HyperException
- If the column has an incompatible type.
-
getString
public java.lang.String getString(int position)
Gets the value of column `position` for the current row as string. Can be used for columns with SQL types: "TEXT", "CHAR", "VARCHAR" and "JSON".- Parameters:
position
- The column for which to retrieve the value.- Returns:
- The value.
- Throws:
HyperException
- If the column has an incompatible type.
-
getBool
public boolean getBool(int position)
Gets the value of column `position` for the current row as boolean. Can be used for columns with SQL type "BOOLEAN".- Parameters:
position
- The column for which to retrieve the value.- Returns:
- The value.
- Throws:
HyperException
- If the column has an incompatible type.
-
getBigDecimal
public java.math.BigDecimal getBigDecimal(int position)
Gets the value of column `position` for the current row as BigDecimal. Can be used for columns with SQL types: "NUMERIC", "BIGINT", "INT" and "SMALLINT".- Parameters:
position
- The column for which to retrieve the value.- Returns:
- The value.
- Throws:
HyperException
- If the column has an incompatible type.
-
getByteArray
public byte[] getByteArray(int position)
Gets the value of column `position` for the current row as byte array. Can be used for columns with SQL types: "BYTES" and "GEOGRAPHY".- Parameters:
position
- The column for which to retrieve the value.- Returns:
- The value.
- Throws:
HyperException
- If the column has an incompatible type.
-
getLocalDate
public java.time.LocalDate getLocalDate(int position)
Gets the value of column `position` for the current row as local date. Can be used for columns with SQL type "DATE".- Parameters:
position
- The column for which to retrieve the value.- Returns:
- The value.
- Throws:
HyperException
- If the column has an incompatible type.
-
getInterval
public Interval getInterval(int position)
Gets the value of column `position` for the current row as interval. Can be used for columns with SQL type "INTERVAL".- Parameters:
position
- The column for which to retrieve the value.- Returns:
- The value.
- Throws:
HyperException
- If the column has an incompatible type.
-
getLocalTime
public java.time.LocalTime getLocalTime(int position)
Gets the value of column `position` for the current row as local time. Can be used for columns with SQL type "TIME".- Parameters:
position
- The column for which to retrieve the value.- Returns:
- The value.
- Throws:
HyperException
- If the column has an incompatible type.
-
getLocalDateTime
public java.time.LocalDateTime getLocalDateTime(int position)
Gets the value of column `position` for the current row as local date time. Can be used for columns with SQL types "TIMESTAMP".- Parameters:
position
- The column for which to retrieve the value.- Returns:
- The value.
- Throws:
HyperException
- If the column has an incompatible type.
-
getZonedDateTime
public java.time.ZonedDateTime getZonedDateTime(int position)
Gets the value of column `position` for the current row as a zoned date time in UTC. Can be used for columns with SQL type "TIMESTAMPTZ".- Parameters:
position
- The column for which to retrieve the value.- Returns:
- The value.
- Throws:
HyperException
- If the column has an incompatible type.
-
getOffsetDateTime
public java.time.OffsetDateTime getOffsetDateTime(int position)
Gets the value of column `position` for the current row as an offset date time in UTC. Can be used for columns with SQL type "TIMESTAMPTZ".- Parameters:
position
- The column for which to retrieve the value.- Returns:
- The value.
- Throws:
HyperException
- If the column has an incompatible type.
-
getRaw
public byte[] getRaw(int position)
Gets the value of column `position` for the current row as a raw value.- Parameters:
position
- The column for which to retrieve the value.- Returns:
- The value as raw value.
-
getObject
public java.lang.Object getObject(int position)
Gets the value of column `position` for the current row as Object.- Parameters:
position
- The column for which to retrieve the value.- Returns:
- The value as Object.
- Throws:
HyperException
- If the column has an unsupported type.
-
-