Packages

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.

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

Abstract Value Members

  1. 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.

    returns

    a Result Future. A successful SELECT query will satisfy the Future with a ResultSet while DML and DDL will be an OK. If there is a server error the Future will be failed with a ServerError exception, not an Error from the Result ADT.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. final def asJava: AsJava

    Provides a Java-friendly API for this PreparedStatement.

  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  10. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. 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.

  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. 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

    select

  18. def select[T](params: Parameter*)(f: (Row) => T): Future[Seq[T]]

    Executes the prepared statement with the given params and maps f to the rows of the returned ResultSet.

    Executes the prepared statement with the given params and maps f to the rows of the returned ResultSet. If no ResultSet is returned, the function returns an empty Seq.

    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

    read

  19. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  20. def toString(): String
    Definition Classes
    AnyRef → Any
  21. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  22. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  23. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped