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");
- Alphabetic
- By Inheritance
- Row
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract val fields: IndexedSeq[Field]
- abstract def indexOf(columnName: String): Option[Int]
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.
- abstract val values: IndexedSeq[Value]
The values for this Row.
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def apply(columnIndex: Option[Int]): Option[Value]
- Attributes
- protected
- def apply(columnName: String): Option[Value]
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.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def bigDecimalOrNull(columnName: String): BigDecimal
Returns a
BigDecimal
for the given column name, ornull
if the SQL value is NULL.Returns a
BigDecimal
for the given column name, ornull
if the SQL value is NULL.This can be used for MySQL columns that are
NewDecimal
,float
, ordouble
.- 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
- def bigIntOrNull(columnName: String): BigInt
Returns a
BigInt
for the given column name, ornull
if the SQL value is NULL.Returns a
BigInt
for the given column name, ornull
if the SQL value is NULL.This can be used for MySQL columns that are
tiny
,short
,int24
,long
, orlonglong
.- 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
- def booleanOrFalse(columnName: String): Boolean
Returns a Java primitive
boolean
for the given column name, orfalse
if the SQL value is NULL.Returns a Java primitive
boolean
for the given column name, orfalse
if the SQL value is NULL.This is used for MySQL columns that are
tiny
asboolean
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
- def byteOrZero(columnName: String): Byte
Returns a Java primitive
byte
for the given column name, or0
if the SQL value is NULL.Returns a Java primitive
byte
for the given column name, or0
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
- def bytesOrNull(columnName: String): Array[Byte]
Returns a
Array[Byte]
for the given column name, ornull
if the SQL value is NULL.Returns a
Array[Byte]
for the given column name, ornull
if the SQL value is NULL.This can be used for MySQL columns that are
tinyblob
,mediumblob
,blob
,binary
, orvarbinary
.- 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
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def doubleOrZero(columnName: String): Double
Returns a Java primitive
double
for the given column name, or0
if the SQL value is NULL.Returns a Java primitive
double
for the given column name, or0
if the SQL value is NULL.This can be used for MySQL columns that are
float
ordouble
.- 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
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def floatOrZero(columnName: String): Float
Returns a Java primitive
float
for the given column name, or0
if the SQL value is NULL.Returns a Java primitive
float
for the given column name, or0
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
- def getBigDecimal(columnName: String): Option[BigDecimal]
Returns
Some
of aBigDecimal
for the given column name, orNone
if the SQL value is NULL.Returns
Some
of aBigDecimal
for the given column name, orNone
if the SQL value is NULL.This can be used for MySQL columns that are
NewDecimal
,float
, ordouble
.- 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
- def getBigInt(columnName: String): Option[BigInt]
Returns
Some
of aBigInt
for the given column name, orNone
if the SQL value is NULL.Returns
Some
of aBigInt
for the given column name, orNone
if the SQL value is NULL.This can be used for MySQL columns that are
tiny
,short
,int24
,long
, orlonglong
.- 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
- def getBoolean(columnName: String): Option[Boolean]
Returns
Some
of a boxed JavaBoolean
for the given column name, orNone
if the SQL value is NULL.Returns
Some
of a boxed JavaBoolean
for the given column name, orNone
if the SQL value is NULL.This is used for MySQL columns that are
tiny
asboolean
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
- def getByte(columnName: String): Option[Byte]
Returns
Some
of a boxed JavaByte
for the given column name, orNone
if the SQL value is NULL.Returns
Some
of a boxed JavaByte
for the given column name, orNone
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
- def getBytes(columnName: String): Option[Array[Byte]]
Returns
Some
of anArray[Byte]
for the given column name, orNone
if the SQL value is NULL.Returns
Some
of anArray[Byte]
for the given column name, orNone
if the SQL value is NULL.This can be used for MySQL columns that are
tinyblob
,mediumblob
,blob
,binary
, orvarbinary
.- 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
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def getDouble(columnName: String): Option[Double]
Returns
Some
of a boxed JavaDouble
for the given column name, orNone
if the SQL value is NULL.Returns
Some
of a boxed JavaDouble
for the given column name, orNone
if the SQL value is NULL.This can be used for MySQL columns that are
float
ordouble
.- 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(
- def getFloat(columnName: String): Option[Float]
Returns
Some
of a boxed JavaFloat
for the given column name, orNone
if the SQL value is NULL.Returns
Some
of a boxed JavaFloat
for the given column name, orNone
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
- def getInteger(columnName: String): Option[Integer]
Returns
Some
of a boxed JavaInteger
for the given column name, orNone
if the SQL value is NULL.Returns
Some
of a boxed JavaInteger
for the given column name, orNone
if the SQL value is NULL.This can be used for MySQL columns that are
tiny
,short
,int24
, or signed andlong
.- 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
- def getJavaSqlDate(columnName: String): Option[Date]
Returns
Some
of ajava.sql.Date
for the given column name, orNone
if the SQL value is NULL.Returns
Some
of ajava.sql.Date
for the given column name, orNone
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(
- def getJsonAsObject[T](columnName: String, objMapper: Serializer)(implicit m: Manifest[T]): Option[T]
Read the value of MySQL
json
column asSome(T)
orNone
if the SQL value is NULL.Read the value of MySQL
json
column asSome(T)
orNone
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 typeT
.
- Exceptions thrown
ColumnNotFoundException
if the column is not found in the row.UnsupportedTypeException
if the MySQL column is not MySQLjson
type.ValueSerializationException
if the MySQL json column value cannot be serialized asT
.- See also
- def getLong(columnName: String): Option[Long]
Returns
Some
of a boxed JavaLong
for the given column name, orNone
if the SQL value is NULL.Returns
Some
of a boxed JavaLong
for the given column name, orNone
if the SQL value is NULL.This can be used for MySQL columns that are
tiny
,short
,int24
,long
, or signed andlonglong
- 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
- def getShort(columnName: String): Option[Short]
Returns
Some
of a boxed JavaShort
for the given column name, orNone
if the SQL value is NULL.Returns
Some
of a boxed JavaShort
for the given column name, orNone
if the SQL value is NULL.This can be used for MySQL columns that are
tiny
, or signed andshort
.- 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
- def getString(columnName: String): Option[String]
Returns
Some
of aString
for the given column name, orNone
if the SQL value is NULL.Returns
Some
of aString
for the given column name, orNone
if the SQL value is NULL.This can be used for MySQL columns that are
varchar
,string
, orvarstring
, Also supportstinyblob
,blob
, andmediumblob
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
- def getTimestamp(columnName: String, timeZone: TimeZone): Option[Timestamp]
Returns
Some
of anjava.sql.Timestamp
for the given column name, orNone
if the SQL value is NULL.Returns
Some
of anjava.sql.Timestamp
for the given column name, orNone
if the SQL value is NULL.This can be used for MySQL columns that are
timestamp
ordatetime
.- 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
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def indexOfOrSentinel(columnName: String): Int
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
- def intOrZero(columnName: String): Int
Returns a Java primitive
int
for the given column name, or0
if the SQL value is NULL.Returns a Java primitive
int
for the given column name, or0
if the SQL value is NULL.This can be used for MySQL columns that are
tiny
,short
,int24
, or signed andlong
.- 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
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def javaSqlDateOrNull(columnName: String): Date
Returns a
java.sql.Date
for the given column name, ornull
if the SQL value is NULL.Returns a
java.sql.Date
for the given column name, ornull
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
- def jsonAsObjectOrNull[T >: Null](columnName: String, objMapper: Serializer)(implicit m: Manifest[T]): T
Read the value of MySQL
json
column as typeT
ornull
if the SQL value is NULL.Read the value of MySQL
json
column as typeT
ornull
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 typeT
.
- Exceptions thrown
ColumnNotFoundException
if the column is not found in the row.UnsupportedTypeException
if the MySQL column is not MySQLjson
type.ValueSerializationException
if the MySQL json column value cannot be serialized asT
.- See also
- def jsonBytesOrNull(columnName: String): Array[Byte]
Read the
Array[Byte]
value of MySQLjson
column ornull
if the SQL value is NULL.Read the
Array[Byte]
value of MySQLjson
column ornull
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 MySQLjson
type.- See also
- def longOrZero(columnName: String): Long
Returns a Java primitive
long
for the given column name, or0
if the SQL value is NULL.Returns a Java primitive
long
for the given column name, or0
if the SQL value is NULL.This can be used for MySQL columns that are
tiny
,short
,int24
,long
, or signed andlonglong
- 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
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def shortOrZero(columnName: String): Short
Returns a Java primitive
short
for the given column name, or0
if the SQL value is NULL.Returns a Java primitive
short
for the given column name, or0
if the SQL value is NULL.This can be used for MySQL columns that are
tiny
, or signed andshort
.- 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
- def stringOrNull(columnName: String): String
Returns a Java
String
for the given column name, ornull
if the SQL value is NULL.Returns a Java
String
for the given column name, ornull
if the SQL value is NULL.This can be used for MySQL columns that are
varchar
,string
, orvarstring
, Also supportstinyblob
,blob
, andmediumblob
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
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def timestampOrNull(columnName: String, timeZone: TimeZone): Timestamp
Returns a
java.sql.Timestamp
for the given column name, ornull
if the SQL value is NULL.Returns a
java.sql.Timestamp
for the given column name, ornull
if the SQL value is NULL.This can be used for MySQL columns that are
timestamp
ordatetime
.- 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
- def toString(): String
- Definition Classes
- Row → AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()