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
BigDecimalfor the given column name, ornullif the SQL value is NULL.Returns a
BigDecimalfor the given column name, ornullif 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
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif the MySQL column is not a supported type.- See also
- def bigIntOrNull(columnName: String): BigInt
Returns a
BigIntfor the given column name, ornullif the SQL value is NULL.Returns a
BigIntfor the given column name, ornullif 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
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif the MySQL column is not a supported type.- See also
- def booleanOrFalse(columnName: String): Boolean
Returns a Java primitive
booleanfor the given column name, orfalseif the SQL value is NULL.Returns a Java primitive
booleanfor the given column name, orfalseif the SQL value is NULL.This is used for MySQL columns that are
tinyasbooleanis a synonym for that type.- columnName
the case sensitive name of the column.
- Exceptions thrown
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif 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
bytefor the given column name, or0if the SQL value is NULL.Returns a Java primitive
bytefor the given column name, or0if the SQL value is NULL.This is used for MySQL columns that are
tinyand signed.- columnName
the case sensitive name of the column.
- Exceptions thrown
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif the MySQL column is not that type.- See also
- def bytesOrNull(columnName: String): Array[Byte]
Returns a
Array[Byte]for the given column name, ornullif the SQL value is NULL.Returns a
Array[Byte]for the given column name, ornullif 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
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif 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
doublefor the given column name, or0if the SQL value is NULL.Returns a Java primitive
doublefor the given column name, or0if the SQL value is NULL.This can be used for MySQL columns that are
floatordouble.- columnName
the case sensitive name of the column.
- Exceptions thrown
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif 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
floatfor the given column name, or0if the SQL value is NULL.Returns a Java primitive
floatfor the given column name, or0if the SQL value is NULL.This is used for MySQL columns that are
float.- columnName
the case sensitive name of the column.
- Exceptions thrown
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif the MySQL column is not a supported type.- See also
- def getBigDecimal(columnName: String): Option[BigDecimal]
Returns
Someof aBigDecimalfor the given column name, orNoneif the SQL value is NULL.Returns
Someof aBigDecimalfor the given column name, orNoneif 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
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif the MySQL column is not a supported type.- See also
- def getBigInt(columnName: String): Option[BigInt]
Returns
Someof aBigIntfor the given column name, orNoneif the SQL value is NULL.Returns
Someof aBigIntfor the given column name, orNoneif 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
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif the MySQL column is not a supported type.- See also
- def getBoolean(columnName: String): Option[Boolean]
Returns
Someof a boxed JavaBooleanfor the given column name, orNoneif the SQL value is NULL.Returns
Someof a boxed JavaBooleanfor the given column name, orNoneif the SQL value is NULL.This is used for MySQL columns that are
tinyasbooleanis a synonym for that type.- columnName
the case sensitive name of the column.
- Exceptions thrown
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif 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
Someof a boxed JavaBytefor the given column name, orNoneif the SQL value is NULL.Returns
Someof a boxed JavaBytefor the given column name, orNoneif 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
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif the MySQL column is not that type.- See also
- def getBytes(columnName: String): Option[Array[Byte]]
Returns
Someof anArray[Byte]for the given column name, orNoneif the SQL value is NULL.Returns
Someof anArray[Byte]for the given column name, orNoneif 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
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif 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
Someof a boxed JavaDoublefor the given column name, orNoneif the SQL value is NULL.Returns
Someof a boxed JavaDoublefor the given column name, orNoneif the SQL value is NULL.This can be used for MySQL columns that are
floatordouble.- columnName
the case sensitive name of the column.
- Exceptions thrown
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif the MySQL column is not a supported type.- See also
doubleOrZero(
- def getFloat(columnName: String): Option[Float]
Returns
Someof a boxed JavaFloatfor the given column name, orNoneif the SQL value is NULL.Returns
Someof a boxed JavaFloatfor the given column name, orNoneif the SQL value is NULL.This is used for MySQL columns that are
float.- columnName
the case sensitive name of the column.
- Exceptions thrown
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif the MySQL column is not a supported type.- See also
- def getInteger(columnName: String): Option[Integer]
Returns
Someof a boxed JavaIntegerfor the given column name, orNoneif the SQL value is NULL.Returns
Someof a boxed JavaIntegerfor the given column name, orNoneif 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
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif the MySQL column is not a supported type.- See also
- def getJavaSqlDate(columnName: String): Option[Date]
Returns
Someof ajava.sql.Datefor the given column name, orNoneif the SQL value is NULL.Returns
Someof ajava.sql.Datefor the given column name, orNoneif 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
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif 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
jsoncolumn asSome(T)orNoneif the SQL value is NULL.Read the value of MySQL
jsoncolumn asSome(T)orNoneif the SQL value is NULL.- columnName
the case sensitive name of the column.
- objMapper
the
objMapperused to parse the json column value into typeT.
- Exceptions thrown
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif the MySQL column is not MySQLjsontype.ValueSerializationExceptionif the MySQL json column value cannot be serialized asT.- See also
- def getLong(columnName: String): Option[Long]
Returns
Someof a boxed JavaLongfor the given column name, orNoneif the SQL value is NULL.Returns
Someof a boxed JavaLongfor the given column name, orNoneif 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
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif the MySQL column is not a supported type.- See also
- def getShort(columnName: String): Option[Short]
Returns
Someof a boxed JavaShortfor the given column name, orNoneif the SQL value is NULL.Returns
Someof a boxed JavaShortfor the given column name, orNoneif 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
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif the MySQL column is not a supported type.- See also
- def getString(columnName: String): Option[String]
Returns
Someof aStringfor the given column name, orNoneif the SQL value is NULL.Returns
Someof aStringfor the given column name, orNoneif the SQL value is NULL.This can be used for MySQL columns that are
varchar,string, orvarstring, Also supportstinyblob,blob, andmediumblobif the field's charset is not the binary charset.- columnName
the case sensitive name of the column.
- Exceptions thrown
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif the MySQL column is not a supported type.- See also
- def getTimestamp(columnName: String, timeZone: TimeZone): Option[Timestamp]
Returns
Someof anjava.sql.Timestampfor the given column name, orNoneif the SQL value is NULL.Returns
Someof anjava.sql.Timestampfor the given column name, orNoneif the SQL value is NULL.This can be used for MySQL columns that are
timestampordatetime.- columnName
the case sensitive name of the column.
- timeZone
the
TimeZoneused to parse the data.
- Exceptions thrown
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif 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
intfor the given column name, or0if the SQL value is NULL.Returns a Java primitive
intfor the given column name, or0if 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
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif 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.Datefor the given column name, ornullif the SQL value is NULL.Returns a
java.sql.Datefor the given column name, ornullif 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
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif 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
jsoncolumn as typeTornullif the SQL value is NULL.Read the value of MySQL
jsoncolumn as typeTornullif the SQL value is NULL.- columnName
the case sensitive name of the column.
- objMapper
the
objMapperused to parse the json column value into typeT.
- Exceptions thrown
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif the MySQL column is not MySQLjsontype.ValueSerializationExceptionif the MySQL json column value cannot be serialized asT.- See also
- def jsonBytesOrNull(columnName: String): Array[Byte]
Read the
Array[Byte]value of MySQLjsoncolumn ornullif the SQL value is NULL.Read the
Array[Byte]value of MySQLjsoncolumn ornullif the SQL value is NULL.- columnName
the case sensitive name of the column.
- Exceptions thrown
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif the MySQL column is not MySQLjsontype.- See also
- def longOrZero(columnName: String): Long
Returns a Java primitive
longfor the given column name, or0if the SQL value is NULL.Returns a Java primitive
longfor the given column name, or0if 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
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif 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
shortfor the given column name, or0if the SQL value is NULL.Returns a Java primitive
shortfor the given column name, or0if 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
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif the MySQL column is not a supported type.- See also
- def stringOrNull(columnName: String): String
Returns a Java
Stringfor the given column name, ornullif the SQL value is NULL.Returns a Java
Stringfor the given column name, ornullif the SQL value is NULL.This can be used for MySQL columns that are
varchar,string, orvarstring, Also supportstinyblob,blob, andmediumblobif the field's charset is not the binary charset.- columnName
the case sensitive name of the column.
- Exceptions thrown
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif 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.Timestampfor the given column name, ornullif the SQL value is NULL.Returns a
java.sql.Timestampfor the given column name, ornullif the SQL value is NULL.This can be used for MySQL columns that are
timestampordatetime.- columnName
the case sensitive name of the column.
- timeZone
the
TimeZoneused to parse the data.
- Exceptions thrown
ColumnNotFoundExceptionif the column is not found in the row.UnsupportedTypeExceptionif 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()