Trait

com.twitter.finagle.mysql

Row

Related Doc: package mysql

Permalink

trait Row extends AnyRef

A Row allows you to extract Value's from a MySQL row.

Column values can be accessed by the MySQL column name via the typed xyzOrNull and getXyz methods. For example, stringOrNull and getString. The get-prefixed methods return Options and use None to represent a SQL NULL. For SQL NULLs, the or-suffixed methods return null for Object-types and use a sentinel, like 0, for primitives.

Alternatively, Value's based on the column name can be accessed via the apply method.

For example, given the query, SELECT 'text' AS str_col, 123 AS int_col, you could extract the columns as such.

First, in Scala:

import com.twitter.finagle.mysql.Row
val row: Row = ???

// if the column is not null:
val strCol: String = row.stringOrNull("str_col")
val intCol: Int = row.intOrZero("int_col")

// if the column is nullable:
val strCol: Option[String] = row.getString("str_col")
val intCol: Option[java.lang.Integer] = row.getInteger("int_col")

Then, the same in Java:

import com.twitter.finagle.mysql.Row;
import scala.Option;
Row row = ...

// if the column is not null:
String strCol = row.stringOrNull("str_col");
int intCol = row.intOrZero("int_col");

// if the column is nullable:
Option<String> strCol = row.getString("str_col");
Option<Integer> intCol = row.getInteger("int_col");
See also

Client.cursor

Client.select

PreparedStatement.select

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Row
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract val fields: IndexedSeq[Field]

    Permalink

    Contains a Field object for each column in the Row.

    Contains a Field object for each column in the Row. The data is 0-indexed so fields(0) contains the column metadata for the first column in the Row.

  2. abstract def indexOf(columnName: String): Option[Int]

    Permalink

    Retrieves the 0-indexed index of the column with the given name.

    Retrieves the 0-indexed index of the column with the given name.

    columnName

    the case sensitive name of the column.

    returns

    Some(Int) if the column exists with the given name. Otherwise, None.

  3. abstract val values: IndexedSeq[Value]

    Permalink

    The values for this Row.

    The values for this Row. The data is 0-indexed so values(0) contains the value for the first column in the Row.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def apply(columnIndex: Option[Int]): Option[Value]

    Permalink
    Attributes
    protected
  5. def apply(columnName: String): Option[Value]

    Permalink

    Retrieves the Value in the column with the given name.

    Retrieves the Value in the column with the given name.

    columnName

    the case sensitive name of the column.

    returns

    Some(Value) if the column exists with the given name. Otherwise, None.

  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. def bigDecimalOrNull(columnName: String): BigDecimal

    Permalink

    Returns a BigDecimal for the given column name, or null if the SQL value is NULL.

    Returns a BigDecimal for the given column name, or null if the SQL value is NULL.

    This can be used for MySQL columns that are NewDecimal, float, or double.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not a supported type.

    See also

    getBigDecimal

  8. def bigIntOrNull(columnName: String): BigInt

    Permalink

    Returns a BigInt for the given column name, or null if the SQL value is NULL.

    Returns a BigInt for the given column name, or null if the SQL value is NULL.

    This can be used for MySQL columns that are tiny, short, int24, long, or longlong.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not a supported type.

    See also

    getBigInt

  9. def booleanOrFalse(columnName: String): Boolean

    Permalink

    Returns a Java primitive boolean for the given column name, or false if the SQL value is NULL.

    Returns a Java primitive boolean for the given column name, or false if the SQL value is NULL.

    This is used for MySQL columns that are tiny as boolean is a synonym for that type.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not that type.

    See also

    https://dev.mysql.com/doc/refman/5.5/en/numeric-type-overview.html

    getBoolean

  10. def byteOrZero(columnName: String): Byte

    Permalink

    Returns a Java primitive byte for the given column name, or 0 if the SQL value is NULL.

    Returns a Java primitive byte for the given column name, or 0 if the SQL value is NULL.

    This is used for MySQL columns that are tiny and signed.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not that type.

    See also

    getByte

  11. def bytesOrNull(columnName: String): Array[Byte]

    Permalink

    Returns a Array[Byte] for the given column name, or null if the SQL value is NULL.

    Returns a Array[Byte] for the given column name, or null if the SQL value is NULL.

    This can be used for MySQL columns that are tinyblob, mediumblob, blob, binary, or varbinary.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not that type.

    See also

    getBytes

  12. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  13. def doubleOrZero(columnName: String): Double

    Permalink

    Returns a Java primitive double for the given column name, or 0 if the SQL value is NULL.

    Returns a Java primitive double for the given column name, or 0 if the SQL value is NULL.

    This can be used for MySQL columns that are float or double.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not a supported type.

    See also

    getDouble

  14. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  16. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. def floatOrZero(columnName: String): Float

    Permalink

    Returns a Java primitive float for the given column name, or 0 if the SQL value is NULL.

    Returns a Java primitive float for the given column name, or 0 if the SQL value is NULL.

    This is used for MySQL columns that are float.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not a supported type.

    See also

    getFloat

  18. def getBigDecimal(columnName: String): Option[BigDecimal]

    Permalink

    Returns Some of a BigDecimal for the given column name, or None if the SQL value is NULL.

    Returns Some of a BigDecimal for the given column name, or None if the SQL value is NULL.

    This can be used for MySQL columns that are NewDecimal, float, or double.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not a supported type.

    See also

    bigDecimalOrNull

  19. def getBigInt(columnName: String): Option[BigInt]

    Permalink

    Returns Some of a BigInt for the given column name, or None if the SQL value is NULL.

    Returns Some of a BigInt for the given column name, or None if the SQL value is NULL.

    This can be used for MySQL columns that are tiny, short, int24, long, or longlong.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not a supported type.

    See also

    bigIntOrNull

  20. def getBoolean(columnName: String): Option[Boolean]

    Permalink

    Returns Some of a boxed Java Boolean for the given column name, or None if the SQL value is NULL.

    Returns Some of a boxed Java Boolean for the given column name, or None if the SQL value is NULL.

    This is used for MySQL columns that are tiny as boolean is a synonym for that type.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not that type.

    See also

    https://dev.mysql.com/doc/refman/5.5/en/numeric-type-overview.html

    booleanOrFalse

  21. def getByte(columnName: String): Option[Byte]

    Permalink

    Returns Some of a boxed Java Byte for the given column name, or None if the SQL value is NULL.

    Returns Some of a boxed Java Byte for the given column name, or None if the SQL value is NULL.

    This is used for MySQL columns that are signed and tiny.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not that type.

    See also

    byteOrZero

  22. def getBytes(columnName: String): Option[Array[Byte]]

    Permalink

    Returns Some of an Array[Byte] for the given column name, or None if the SQL value is NULL.

    Returns Some of an Array[Byte] for the given column name, or None if the SQL value is NULL.

    This can be used for MySQL columns that are tinyblob, mediumblob, blob, binary, or varbinary.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not that type.

    See also

    bytesOrNull

  23. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  24. def getDouble(columnName: String): Option[Double]

    Permalink

    Returns Some of a boxed Java Double for the given column name, or None if the SQL value is NULL.

    Returns Some of a boxed Java Double for the given column name, or None if the SQL value is NULL.

    This can be used for MySQL columns that are float or double.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not a supported type.

    See also

    doubleOrZero(

  25. def getFloat(columnName: String): Option[Float]

    Permalink

    Returns Some of a boxed Java Float for the given column name, or None if the SQL value is NULL.

    Returns Some of a boxed Java Float for the given column name, or None if the SQL value is NULL.

    This is used for MySQL columns that are float.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not a supported type.

    See also

    floatOrZero

  26. def getInteger(columnName: String): Option[Integer]

    Permalink

    Returns Some of a boxed Java Integer for the given column name, or None if the SQL value is NULL.

    Returns Some of a boxed Java Integer for the given column name, or None if the SQL value is NULL.

    This can be used for MySQL columns that are tiny, short, int24, or signed and long.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not a supported type.

    See also

    intOrZero

  27. def getJavaSqlDate(columnName: String): Option[Date]

    Permalink

    Returns Some of a java.sql.Date for the given column name, or None if the SQL value is NULL.

    Returns Some of a java.sql.Date for the given column name, or None if the SQL value is NULL.

    This can be used for MySQL columns that are date.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not a supported type.

    See also

    javaSqlDateOrNull(

  28. def getJsonAsObject[T](columnName: String, objMapper: Serializer)(implicit m: Manifest[T]): Option[T]

    Permalink

    Read the value of MySQL json column as Some(T) or None if the SQL value is NULL.

    Read the value of MySQL json column as Some(T) or None if the SQL value is NULL.

    columnName

    the case sensitive name of the column.

    objMapper

    the objMapper used to parse the json column value into type T.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not MySQL json type.

    ValueSerializationException if the MySQL json column value cannot be serialized as T.

    See also

    jsonAsObjectOrNull

  29. def getLong(columnName: String): Option[Long]

    Permalink

    Returns Some of a boxed Java Long for the given column name, or None if the SQL value is NULL.

    Returns Some of a boxed Java Long for the given column name, or None if the SQL value is NULL.

    This can be used for MySQL columns that are tiny, short, int24, long, or signed and longlong

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not a supported type.

    See also

    longOrZero

  30. def getShort(columnName: String): Option[Short]

    Permalink

    Returns Some of a boxed Java Short for the given column name, or None if the SQL value is NULL.

    Returns Some of a boxed Java Short for the given column name, or None if the SQL value is NULL.

    This can be used for MySQL columns that are tiny, or signed and short.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not a supported type.

    See also

    shortOrZero

  31. def getString(columnName: String): Option[String]

    Permalink

    Returns Some of a String for the given column name, or None if the SQL value is NULL.

    Returns Some of a String for the given column name, or None if the SQL value is NULL.

    This can be used for MySQL columns that are varchar, string, or varstring, Also supports tinyblob, blob, and mediumblob if the field's charset is not the binary charset.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not a supported type.

    See also

    stringOrNull

  32. def getTimestamp(columnName: String, timeZone: TimeZone): Option[Timestamp]

    Permalink

    Returns Some of an java.sql.Timestamp for the given column name, or None if the SQL value is NULL.

    Returns Some of an java.sql.Timestamp for the given column name, or None if the SQL value is NULL.

    This can be used for MySQL columns that are timestamp or datetime.

    columnName

    the case sensitive name of the column.

    timeZone

    the TimeZone used to parse the data.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not that type.

    See also

    timestampOrNull

  33. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  34. def indexOfOrSentinel(columnName: String): Int

    Permalink

    Retrieves the 0-indexed index of the column with the given name.

    Retrieves the 0-indexed index of the column with the given name.

    columnName

    the case sensitive name of the column.

    returns

    -1 if the column does not exist, otherwise the index of the column.

    Attributes
    protected
  35. def intOrZero(columnName: String): Int

    Permalink

    Returns a Java primitive int for the given column name, or 0 if the SQL value is NULL.

    Returns a Java primitive int for the given column name, or 0 if the SQL value is NULL.

    This can be used for MySQL columns that are tiny, short, int24, or signed and long.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not a supported type.

    See also

    getInteger

  36. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  37. def javaSqlDateOrNull(columnName: String): Date

    Permalink

    Returns a java.sql.Date for the given column name, or null if the SQL value is NULL.

    Returns a java.sql.Date for the given column name, or null if the SQL value is NULL.

    This can be used for MySQL columns that are date.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not a supported type.

    See also

    getJavaSqlDate

  38. def jsonAsObjectOrNull[T >: Null](columnName: String, objMapper: Serializer)(implicit m: Manifest[T]): T

    Permalink

    Read the value of MySQL json column as type T or null if the SQL value is NULL.

    Read the value of MySQL json column as type T or null if the SQL value is NULL.

    columnName

    the case sensitive name of the column.

    objMapper

    the objMapper used to parse the json column value into type T.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not MySQL json type.

    ValueSerializationException if the MySQL json column value cannot be serialized as T.

    See also

    getJsonAsObject

  39. def jsonBytesOrNull(columnName: String): Array[Byte]

    Permalink

    Read the Array[Byte] value of MySQL json column or null if the SQL value is NULL.

    Read the Array[Byte] value of MySQL json column or null if the SQL value is NULL.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not MySQL json type.

    See also

    jsonAsObjectOrNull

  40. def longOrZero(columnName: String): Long

    Permalink

    Returns a Java primitive long for the given column name, or 0 if the SQL value is NULL.

    Returns a Java primitive long for the given column name, or 0 if the SQL value is NULL.

    This can be used for MySQL columns that are tiny, short, int24, long, or signed and longlong

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not a supported type.

    See also

    getLong

  41. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  42. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  43. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  44. def shortOrZero(columnName: String): Short

    Permalink

    Returns a Java primitive short for the given column name, or 0 if the SQL value is NULL.

    Returns a Java primitive short for the given column name, or 0 if the SQL value is NULL.

    This can be used for MySQL columns that are tiny, or signed and short.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not a supported type.

    See also

    getShort

  45. def stringOrNull(columnName: String): String

    Permalink

    Returns a Java String for the given column name, or null if the SQL value is NULL.

    Returns a Java String for the given column name, or null if the SQL value is NULL.

    This can be used for MySQL columns that are varchar, string, or varstring, Also supports tinyblob, blob, and mediumblob if the field's charset is not the binary charset.

    columnName

    the case sensitive name of the column.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not a supported type.

    See also

    getString

  46. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  47. def timestampOrNull(columnName: String, timeZone: TimeZone): Timestamp

    Permalink

    Returns a java.sql.Timestamp for the given column name, or null if the SQL value is NULL.

    Returns a java.sql.Timestamp for the given column name, or null if the SQL value is NULL.

    This can be used for MySQL columns that are timestamp or datetime.

    columnName

    the case sensitive name of the column.

    timeZone

    the TimeZone used to parse the data.

    Exceptions thrown

    ColumnNotFoundException if the column is not found in the row.

    UnsupportedTypeException if the MySQL column is not that type.

    See also

    getTimestamp

  48. def toString(): String

    Permalink
    Definition Classes
    Row → AnyRef → Any
  49. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  50. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  51. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped