trait PreparedStatement extends AnyRef
A PreparedStatement
represents a parameterized SQL statement which may be
applied concurrently with varying parameters.
These are SQL statements with ?
's used for the parameters which are
"filled in" per usage by read
, select
, and modify
.
- See also
Client.prepare(String)
CursoredStatement for a lazy stream of Rows.
- Alphabetic
- By Inheritance
- PreparedStatement
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def apply(params: Parameter*): Future[Result]
Executes the prepared statement with the given
params
.Executes the prepared statement with the given
params
.Note: this is a lower-level API. For SELECT queries, prefer using select or read, and use modify for DML (INSERT/UPDATE/DELETE) and DDL.
For Scala users, you can use the implicit conversions to Parameter by importing
Parameter._
. For example:import com.twitter.finagle.mysql.{Client, PreparedStatement, Result} import com.twitter.finagle.mysql.Parameter._ import com.twitter.util.Future val client: Client = ??? val preparedStatement: PreparedStatement = client.prepare("INSERT INTO a_table (column1, column2) VALUES (?, ?)") // note the implicit conversions of the String and Int to Parameters val result: Future[Result] = preparedStatement("value1", 1234)
Java users, see asJava and use PreparedStatement.AsJava.execute.
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
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- final def asJava: AsJava
Provides a Java-friendly API for this PreparedStatement.
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- 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])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def modify(params: Parameter*): Future[OK]
Executes the prepared statement DML (e.g.
Executes the prepared statement DML (e.g. INSERT/UPDATE/DELETE) or DDL (e.g. CREATE TABLE, DROP TABLE, COMMIT, START TRANSACTION, etc) with the given
params
.For Scala users, you can use the implicit conversions to Parameter by importing
Parameter._
. For example:import com.twitter.finagle.mysql.{Client, OK, PreparedStatement} import com.twitter.finagle.mysql.Parameter._ import com.twitter.util.Future val client: Client = ??? val preparedStatement: PreparedStatement = client.prepare("INSERT INTO a_table (column1, column2) VALUES (?, ?)") // note the implicit conversions of the String and Int to Parameters val ok: Future[OK] = preparedStatement.modify("value1", 1234)
Java users, see asJava and use PreparedStatement.AsJava.modify.
- 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 read(params: Parameter*): Future[ResultSet]
Executes the prepared statement SELECT query with the given
params
.Executes the prepared statement SELECT query with the given
params
.For Scala users, you can use the implicit conversions to Parameter by importing
Parameter._
. For example:import com.twitter.finagle.mysql.{Client, PreparedStatement, ResultSet} import com.twitter.finagle.mysql.Parameter._ import com.twitter.util.Future val client: Client = ??? val preparedStatement: PreparedStatement = client.prepare("SELECT column1 FROM a_table WHERE column2 = ? AND column3 = ?)") // note the implicit conversions of the String and Int to Parameters val resultSet: Future[ResultSet] = preparedStatement.read("value1", 1234)
Java users, see asJava and use PreparedStatement.AsJava.read.
- See also
- def select[T](params: Parameter*)(f: (Row) => T): Future[Seq[T]]
Executes the prepared statement with the given
params
and mapsf
to the rows of the returned ResultSet.Executes the prepared statement with the given
params
and mapsf
to the rows of the returned ResultSet. If no ResultSet is returned, the function returns an emptySeq
.For Scala users, you can use the implicit conversions to Parameter by importing
Parameter._
. For example:import com.twitter.finagle.mysql.{Client, PreparedStatement, StringValue} import com.twitter.finagle.mysql.Parameter._ import com.twitter.util.Future val client: Client = ??? val preparedStatement: PreparedStatement = client.prepare("SELECT column1 FROM a_table WHERE column2 = ?") // note the implicit conversion of the Int, 1234, into a Parameter val result: Future[Seq[String] = preparedStatement.select(1234) { row => row.stringOrNull("column1") }
Java users, see asJava and use PreparedStatement.AsJava.select.
- See also
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- 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()