Class SQLRow

java.lang.Object
com.blackrook.sql.SQLRow

public class SQLRow extends Object
SQLRow object. Represents one row in a query result, mapped using column names. Contains methods for auto-casting or converting the row data.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    getBoolean(int columnIndex)
    Gets the boolean value of a column.
    boolean
    getBoolean(String columnName)
    Gets the boolean value of a column.
    byte
    getByte(int columnIndex)
    Gets the byte value of a column.
    byte
    getByte(String columnName)
    Gets the byte value of a column.
    byte[]
    getByteArray(int columnIndex)
    Gets the byte array value of a column, if this can be represented as such (usually Blobs).
    byte[]
    getByteArray(String columnName)
    Gets the byte array value of a column, if this can be represented as such (usually Blobs).
    getDate(int columnIndex)
    Gets the Date value of the object, or null if not a Date.
    getDate(String columnName)
    Gets the Date value of the object, or null if not a Date.
    double
    getDouble(int columnIndex)
    Gets the double value of a column.
    double
    getDouble(String columnName)
    Gets the double value of a column.
    float
    getFloat(int columnIndex)
    Gets the float value of a column.
    float
    getFloat(String columnName)
    Gets the float value of a column.
    int
    getInt(int columnIndex)
    Gets the integer value of a column.
    int
    getInt(String columnName)
    Gets the integer value of a column.
    long
    getLong(int columnIndex)
    Gets the long value of a column.
    long
    getLong(String columnName)
    Gets the long value of a column.
    boolean
    getNull(int columnIndex)
    Gets if a column's value is null.
    boolean
    getNull(String columnName)
    Gets if a column's value is null.
    short
    getShort(int columnIndex)
    Gets the short value of a column.
    short
    getShort(String columnName)
    Gets the short value of a column.
    getString(int columnIndex)
    Gets the string value of a column.
    getString(String columnName)
    Gets the string value of a column.
    getTimestamp(int columnIndex)
    Gets the Timestamp value of the object, or null if not a Timestamp or Date.
    getTimestamp(String columnName)
    Gets the Timestamp value of the object, or null if not a Timestamp or Date.

    Methods inherited from class java.lang.Object

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

    • getNull

      public boolean getNull(int columnIndex)
      Gets if a column's value is null.
      Parameters:
      columnIndex - the column index to read (0-based).
      Returns:
      the resultant value, or null if not a valid column name.
    • getNull

      public boolean getNull(String columnName)
      Gets if a column's value is null.
      Parameters:
      columnName - the column name to read (case-insensitive).
      Returns:
      the resultant value, or null if not a valid column name.
    • getBoolean

      public boolean getBoolean(int columnIndex)
      Gets the boolean value of a column. Can convert from Booleans, Numbers, and Strings.
      Parameters:
      columnIndex - the column index to read (0-based).
      Returns:
      the resultant value, or null if not a valid column name.
    • getBoolean

      public boolean getBoolean(String columnName)
      Gets the boolean value of a column. Can convert from Booleans, Numbers, and Strings.
      Parameters:
      columnName - the column name to read (case-insensitive).
      Returns:
      the resultant value, or null if not a valid column name.
    • getByte

      public byte getByte(int columnIndex)
      Gets the byte value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.
      Parameters:
      columnIndex - the column index to read (0-based).
      Returns:
      the resultant value, or null if not a valid column name.
    • getByte

      public byte getByte(String columnName)
      Gets the byte value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.
      Parameters:
      columnName - the column name to read (case-insensitive).
      Returns:
      the resultant value, or null if not a valid column name.
    • getByteArray

      public byte[] getByteArray(int columnIndex)
      Gets the byte array value of a column, if this can be represented as such (usually Blobs). Can convert from Blobs.
      Parameters:
      columnIndex - the column index to read (0-based).
      Returns:
      the resultant value, or null if not a valid column name.
    • getByteArray

      public byte[] getByteArray(String columnName)
      Gets the byte array value of a column, if this can be represented as such (usually Blobs). Can convert from Blobs.
      Parameters:
      columnName - the column name to read (case-insensitive).
      Returns:
      the resultant value, or null if not a valid column name.
    • getShort

      public short getShort(int columnIndex)
      Gets the short value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.
      Parameters:
      columnIndex - the column index to read (0-based).
      Returns:
      the resultant value, or null if not a valid column name.
    • getShort

      public short getShort(String columnName)
      Gets the short value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.
      Parameters:
      columnName - the column name to read (case-insensitive).
      Returns:
      the resultant value, or null if not a valid column name.
    • getInt

      public int getInt(int columnIndex)
      Gets the integer value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.
      Parameters:
      columnIndex - the column index to read (0-based).
      Returns:
      the resultant value, or null if not a valid column name.
    • getInt

      public int getInt(String columnName)
      Gets the integer value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.
      Parameters:
      columnName - the column name to read (case-insensitive).
      Returns:
      the resultant value, or null if not a valid column name.
    • getFloat

      public float getFloat(int columnIndex)
      Gets the float value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.
      Parameters:
      columnIndex - the column index to read (0-based).
      Returns:
      the resultant value, or null if not a valid column name.
    • getFloat

      public float getFloat(String columnName)
      Gets the float value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.
      Parameters:
      columnName - the column name to read (case-insensitive).
      Returns:
      the resultant value, or null if not a valid column name.
    • getLong

      public long getLong(int columnIndex)
      Gets the long value of a column. Can convert from Booleans, Numbers, Strings, and Dates/Timestamps. Booleans convert to 1 if true, 0 if false. Dates and Timestamps convert to milliseconds since the Epoch.
      Parameters:
      columnIndex - the column index to read (0-based).
      Returns:
      the resultant value, or null if not a valid column name.
    • getLong

      public long getLong(String columnName)
      Gets the long value of a column. Can convert from Booleans, Numbers, Strings, and Dates/Timestamps. Booleans convert to 1 if true, 0 if false. Dates and Timestamps convert to milliseconds since the Epoch.
      Parameters:
      columnName - the column name to read (case-insensitive).
      Returns:
      the resultant value, or null if not a valid column name.
    • getDouble

      public double getDouble(int columnIndex)
      Gets the double value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.
      Parameters:
      columnIndex - the column index to read (0-based).
      Returns:
      the resultant value, or null if not a valid column name.
    • getDouble

      public double getDouble(String columnName)
      Gets the double value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.
      Parameters:
      columnName - the column name to read (case-insensitive).
      Returns:
      the resultant value, or null if not a valid column name.
    • getString

      public String getString(int columnIndex)
      Gets the string value of a column. Can convert from Booleans, Numbers, byte and char arrays, Blobs, and Clobs. Booleans convert to 1 if true, 0 if false. Byte arrays and Blobs are converted using the native charset encoding. Char arrays and Clobs are read entirely and converted to Strings.
      Parameters:
      columnIndex - the column index to read (0-based).
      Returns:
      the resultant value, or null if not a valid column name.
      See Also:
    • getString

      public String getString(String columnName)
      Gets the string value of a column. Can convert from Booleans, Numbers, byte and char arrays, Blobs, and Clobs. Booleans convert to 1 if true, 0 if false. Byte arrays and Blobs are converted using the native charset encoding. Char arrays and Clobs are read entirely and converted to Strings.
      Parameters:
      columnName - the column name to read (case-insensitive).
      Returns:
      the resultant value, or null if not a valid column name.
      See Also:
    • getTimestamp

      public Timestamp getTimestamp(int columnIndex)
      Gets the Timestamp value of the object, or null if not a Timestamp or Date.
      Parameters:
      columnIndex - the column index to read (0-based).
      Returns:
      the resultant value, or null if not a valid column name.
    • getTimestamp

      public Timestamp getTimestamp(String columnName)
      Gets the Timestamp value of the object, or null if not a Timestamp or Date.
      Parameters:
      columnName - the column name to read (case-insensitive).
      Returns:
      the resultant value, or null if not a valid column name.
    • getDate

      public Date getDate(int columnIndex)
      Gets the Date value of the object, or null if not a Date.
      Parameters:
      columnIndex - the column index to read (0-based).
      Returns:
      the resultant value, or null if not a valid column name.
    • getDate

      public Date getDate(String columnName)
      Gets the Date value of the object, or null if not a Date.
      Parameters:
      columnName - the column name to read (case-insensitive).
      Returns:
      the resultant value, or null if not a valid column name.