Class Result

java.lang.Object
com.tableau.hyperapi.Result
All Implemented Interfaces:
AutoCloseable

public final class Result extends Object implements AutoCloseable
A query result.

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.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes this result object, relinquishing the underlying native handles.
    Gets the number of rows affected by the SQL command.
    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.
    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.
    getInterval(int position)
    Gets the value of column `position` for the current row as interval.
    getLocalDate(int position)
    Gets the value of column `position` for the current row as local date.
    getLocalDateTime(int position)
    Gets the value of column `position` for the current row as local date time.
    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.
    getObject(int position)
    Gets the value of column `position` for the current row as Object.
    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.
    Gets the schema of the result.
    short
    getShort(int position)
    Gets the value of column `position` for the current row as short.
    getString(int position)
    Gets the value of column `position` for the current row as string.
    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
    Returns whether the result is open.
    boolean
    Gets the next row of the result.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • close

      public void close()
      Closes this result object, relinquishing the underlying native handles.
      Specified by:
      close in interface 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 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 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 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 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 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 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 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 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 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.