Trait/Object

com.twitter.finagle.mysql

PreparedStatement

Related Docs: object PreparedStatement | package mysql

Permalink

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

CursoredStatement for a lazy stream of Rows.

Client.prepare(String)

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

Abstract Value Members

  1. abstract def apply(params: Parameter*): Future[Result]

    Permalink

    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

    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. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. final def asJava: AsJava

    Permalink

    Provides a Java-friendly API for this PreparedStatement.

  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

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

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  13. def modify(params: Parameter*): Future[OK]

    Permalink

    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

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

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

    Permalink
    Definition Classes
    AnyRef
  17. def read(params: Parameter*): Future[ResultSet]

    Permalink

    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]]

    Permalink

    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

    Permalink
    Definition Classes
    AnyRef
  20. def toString(): String

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

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

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

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

Inherited from AnyRef

Inherited from Any

Ungrouped