Trait

io.rdbc.sapi

Connection

Related Doc: package sapi

Permalink

trait Connection extends AnyRef

Represents a database connection (session).

Instances of implementations of this trait can be obtained using a ConnectionFactory. When clients are done with the connection, they are required to call a release method co clean up resources such as open sockets.

Invoking any method of this trait when any previous operation has not completed yet is not allowed. Operation is considered complete when a resulting Future completes.

Transaction management has to be done using beginTx, commitTx and rollbackTx methods. Using SQL statements to manage transaction state is not allowed.

SqlWithParams instances passed to Connection's methods can be created using sql string interpolator, for example:

import io.rdbc.sapi._

val conn: Connection = ???
val login = "jdoe"
conn.statement(sql"select * from users where login = $login").executeForStream()

Alternatively, when bare Strings are used as SQL statements, parameters are specified by name. Parameter name is an alphanumeric string starting with a letter, prefixed with a colon. Example:

import io.rdbc.sapi._

val conn: Connection = ???
val login = "jdoe"
conn.statement(sql"select * from users where login = :login")
    .bind("login" -> login)
    .executable.executeForStream()
Linear Supertypes
AnyRef, Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. Connection
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def beginTx()(implicit timeout: Timeout): Future[Unit]

    Permalink

    Begins a database transaction.

    Begins a database transaction.

    Using this method is a preferred way of starting a transaction, using SQL statements to manage transaction state may lead to undefined behavior.

    After the operation takes longer time than timeout, operation will be aborted. Note however, that it may not be feasible to abort the operation immediately.

    Returned future can fail with:

  2. abstract def commitTx()(implicit timeout: Timeout): Future[Unit]

    Permalink

    Commits a database transaction.

    Commits a database transaction.

    Using this method is a preferred way of committing a transaction, using SQL statements to manage transaction state may lead to undefined behavior.

    After the operation takes longer time than timeout, operation will be aborted. Note however, that it may not be feasible to abort the operation immediately.

    Returned future can fail with:

  3. abstract def forceRelease(): Future[Unit]

    Permalink

    Releases the connection and underlying resources regardless of whether the connection is currently in use or not.

    Releases the connection and underlying resources regardless of whether the connection is currently in use or not.

    After calling this method no future operations on the instance are allowed.

    Returned future can fail with:

  4. abstract def release(): Future[Unit]

    Permalink

    Releases the connection and underlying resources.

    Releases the connection and underlying resources.

    Only idle connections can be released using this method. To forcibly release the connection use forceRelease method.

    After calling this method no future operations on the instance are allowed.

    Returned future can fail with:

  5. abstract def rollbackTx()(implicit timeout: Timeout): Future[Unit]

    Permalink

    Rolls back a database transaction.

    Rolls back a database transaction.

    Using this method is a preferred way of rolling back a transaction, using SQL statements to manage transaction state may lead to undefined behavior.

    After the operation takes longer time than timeout, operation will be aborted. Note however, that it may not be feasible to abort the operation immediately.

    Returned future can fail with:

  6. abstract def statement(sqlWithParams: SqlWithParams): ExecutableStatement

    Permalink

    Returns a ExecutableStatement instance bound to this connection that represents any parametrized SQL statement.

    Returns a ExecutableStatement instance bound to this connection that represents any parametrized SQL statement.

    It's a shortcut for calling statement and then bind.

    SqlWithParams parameter instance is meant to be constructed using sql string interpolator, for example:

    import io.rdbc.sapi.Interpolators._
    val x = 1
    val y = 10
    val stmt = conn.statement(sql"select * from table where colx > $x and coly < $y")

    Throws:

  7. abstract def statement(sqlWithParams: SqlWithParams, statementOptions: StatementOptions): ExecutableStatement

    Permalink

    Returns a ExecutableStatement instance bound to this connection that represents any parametrized SQL statement.

    Returns a ExecutableStatement instance bound to this connection that represents any parametrized SQL statement.

    It's a shortcut for calling statement and then bind.

    SqlWithParams parameter instance is meant to be constructed using sql string interpolator, for example:

    import io.rdbc.sapi.Interpolators._
    val x = 1
    val y = 10
    val stmt = conn.statement(sql"select * from table where colx > $x and coly < $y")

    Throws:

  8. abstract def statement(sql: String): Statement

    Permalink

    Returns a Statement instance bound to this connection that represents any SQL statement.

    Returns a Statement instance bound to this connection that represents any SQL statement.

    For syntax of statement parametrization see a Connection documentation.

    Throws:

  9. abstract def statement(sql: String, statementOptions: StatementOptions): Statement

    Permalink

    Returns a Statement instance bound to this connection that represents any SQL statement.

    Returns a Statement instance bound to this connection that represents any SQL statement.

    For syntax of statement parametrization see a Connection documentation.

    Throws:

  10. abstract def validate()(implicit timeout: Timeout): Future[Unit]

    Permalink

    Checks whether the connection is still usable.

    Checks whether the connection is still usable.

    If checking takes longer than timeout, connection is considered unusable.

    returns

    Successful future of unit iff connection is usable, future failed with ConnectionValidationException otherwise.

  11. abstract def watchForIdle: Future[Connection.this.type]

    Permalink

    Returns a future that is complete when this connection is idle and ready for accepting queries.

  12. abstract def withTransaction[A](body: ⇒ Future[A])(implicit timeout: Timeout): Future[A]

    Permalink

    Executes a function in a context of a transaction.

    Executes a function in a context of a transaction.

    Executes a function (which can be passed as a code block) in a context of a transaction. Before the function is executed, transaction is started. After the function finishes, transaction is committed in case of a success and rolled back in case of a failure.

    Because managing transaction state requires invoking functions that require specifying a timeout, this function requires an implicit timeout instance.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from Connection to any2stringadd[Connection] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (Connection, B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from Connection to ArrowAssoc[Connection] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def ensuring(cond: (Connection) ⇒ Boolean, msg: ⇒ Any): Connection

    Permalink
    Implicit information
    This member is added by an implicit conversion from Connection to Ensuring[Connection] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  9. def ensuring(cond: (Connection) ⇒ Boolean): Connection

    Permalink
    Implicit information
    This member is added by an implicit conversion from Connection to Ensuring[Connection] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  10. def ensuring(cond: Boolean, msg: ⇒ Any): Connection

    Permalink
    Implicit information
    This member is added by an implicit conversion from Connection to Ensuring[Connection] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  11. def ensuring(cond: Boolean): Connection

    Permalink
    Implicit information
    This member is added by an implicit conversion from Connection to Ensuring[Connection] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. final def eq(arg0: AnyRef): Boolean

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

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  15. def formatted(fmtstr: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from Connection to StringFormat[Connection] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  16. final def getClass(): Class[_]

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

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

    Permalink
    Definition Classes
    Any
  19. final def ne(arg0: AnyRef): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  22. final def synchronized[T0](arg0: ⇒ T0): T0

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

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

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. def [B](y: B): (Connection, B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from Connection to ArrowAssoc[Connection] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from Connection to any2stringadd[Connection]

Inherited by implicit conversion StringFormat from Connection to StringFormat[Connection]

Inherited by implicit conversion Ensuring from Connection to Ensuring[Connection]

Inherited by implicit conversion ArrowAssoc from Connection to ArrowAssoc[Connection]

Transaction management

Statement producers (string interpolation)

Statement producers (bare strings)

Ungrouped