scalikejdbc

package scalikejdbc

ScalikeJDBC - SQL-Based DB Access Library for Scala

Just write SQL:

ScalikeJDBC is a SQL-based DB access library for Scala developers. This library naturally wraps JDBC APIs and provides you easy-to-use APIs. Users do nothing other than writing SQL and mapping from java.sql.ResultSet objects to Scala values.

Basic Usage:

Using scalikejdbc.DBSession:

import scalikejdbc._
import org.joda.time.DateTime
case class User(id: Long, name: String, birthday: Option[DateTime])

val activeUsers: List[User] = DB readOnly { session =>
  session.list("select * from users where active = ?", true) { rs =>
    User(id = rs.long("id"), name = rs.string("name"), birthday = Option(rs.date("birthday")).map(_.toDateTime))
  }
}

Using scalikejdbc.SQL:

import scalikejdbc._
import org.joda.time.DateTime
case class User(id: Long, name: String, birthday: Option[DateTime])

val activeUsers: List[User] = DB readOnly { implicit session =>
  SQL("select * from users where active = ?")
    .bind(true)
    .map { rs => User(id = rs.long("id"), name = rs.string("name"), birthday = Option(rs.date("birthday")).map(_.toDateTime)) }.list.apply()
}

or

val activeUsers: List[User] = DB readOnly { implicit session =>
SQL("select * from users where active = /*'active*/rue")
  .bindByName('active -> true)
  .map { rs => User(id = rs.long("id"), name = rs.string("name"), birthday = Option(rs.date("birthday")).map(_.toDateTime)) }.list.apply()
}
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. scalikejdbc
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. case class ActiveSession(conn: Connection, tx: Option[Tx] = scala.None, isReadOnly: Boolean = false) extends DBSession with Product with Serializable

    Active session implementation of scalikejdbc.DBSession.

  2. type Closable = AnyRef { def close(): Unit }

  3. class CommonsConnectionPool extends ConnectionPool

    Commons DBCP Connection Pool

  4. abstract class ConnectionPool extends AnyRef

    Connection Pool

  5. trait ConnectionPoolContext extends AnyRef

    Connection pool context

  6. trait ConnectionPoolFactory extends AnyRef

    Connection Pool Factory

  7. case class ConnectionPoolSettings(initialSize: Int = 0, maxSize: Int = 8, validationQuery: String = null) extends Product with Serializable

    Settings for ConnectionPool

  8. case class DB(conn: Connection) extends LogSupport with Product with Serializable

    Basic Database Accessor

  9. trait DBSession extends LogSupport

    DB Session

  10. trait HasExtractor extends WithExtractor

    Represents that this SQL already has an extractor

  11. class LocalTimeConverter extends AnyRef

    org.joda.time.LocalTime converter.

  12. case class LoggingSQLAndTimeSettings(enabled: Boolean = true, logLevel: Symbol = scala.Symbol.apply("debug"), warningEnabled: Boolean = false, warningThresholdMillis: Long = 3000L, warningLogLevel: Symbol = scala.Symbol.apply("warn")) extends Product with Serializable

    Settings for logging SQL and timing

  13. case class MultipleConnectionPoolContext(contexts: (Any, ConnectionPool)*) extends ConnectionPoolContext with Product with Serializable

    Multiple connection pool context

  14. case class NamedAutoSession(name: Any) extends DBSession with Product with Serializable

    Represents that already existing session will be used or a new session which is retrieved from named connection pool will be started.

  15. case class NamedDB(name: Any)(implicit context: ConnectionPoolContext = NoConnectionPoolContext) extends Product with Serializable

    Named Basic DB Accessor

  16. trait NoExtractor extends WithExtractor

    Represents that this SQL doesn't have an extractor yet

  17. class ResultSetCursor extends AnyRef

    java.sql.ResultSet cursor

  18. class ResultSetTraversable extends Traversable[WrappedResultSet]

    scala.collection.Traversable object which wraps java.sql.ResultSet

  19. abstract class SQL[A, E <: WithExtractor] extends AnyRef

    SQL abstraction.

  20. class SQLBatch extends AnyRef

    SQL which execute java.sql.Statement#executeBatch().

  21. class SQLExecution extends AnyRef

    SQL which execute java.sql.Statement#execute().

  22. class SQLToList[A, E <: WithExtractor] extends SQL[A, E]

    SQL which exeute java.sql.Statement#executeQuery() and returns the result as scala.collection.immutable.List value.

  23. class SQLToOption[A, E <: WithExtractor] extends SQL[A, E]

    SQL which exeute java.sql.Statement#executeQuery() and returns the result as scala.Option value.

  24. class SQLToTraversable[A, E <: WithExtractor] extends SQL[A, E]

    SQL which exeute java.sql.Statement#executeQuery() and returns the result as scala.collection.Traversable value.

  25. class SQLUpdate extends AnyRef

    SQL which execute java.sql.Statement#exeuteUpdate().

  26. class SQLUpdateWithGeneratedKey extends AnyRef

    SQL which execute java.sql.Statement#exeuteUpdate() and get generated key value.

  27. class ScalaBigDecimalConverter extends AnyRef

    BigDecimal converter.

  28. case class StatementExecutor(underlying: PreparedStatement, template: String, singleParams: Seq[Any] = immutable.this.Nil, isBatch: Boolean = false) extends LogSupport with Product with Serializable

    java.sql.Statement Executor

  29. case class StringSQLRunner(sql: String) extends Product with Serializable

    String SQL Runner

  30. case class TooManyRowsException(expected: Int, actual: Int) extends Exception with Product with Serializable

    Exception which represents too many rows returned.

  31. class Tx extends AnyRef

    DB Transaction abstraction.

  32. class UnixTimeInMillisConverter extends AnyRef

    Unix Time Converter to several types.

  33. sealed trait WithExtractor extends AnyRef

    Represents an extractor is already specified or not

  34. case class WrappedResultSet(underlying: ResultSet, cursor: ResultSetCursor, index: Int) extends Product with Serializable

    java.sql.ResultSet wrapper

Value Members

  1. object AutoSession extends DBSession with Product with Serializable

    Represents that already existing session will be used or a new session will be started.

  2. object CommonsConnectionPoolFactory extends ConnectionPoolFactory

    Connection Pool Factory

  3. object ConnectionPool extends LogSupport

    Connection Pool

  4. object DB extends Serializable

    Basic Database Accessor

  5. object DBSession

  6. object GeneralizedTypeConstraintsForWithExtractor

    Generalized type constraints for WithExtractor

  7. object GlobalSettings

    GlobalSettings for this library

  8. object LoanPattern

    Loan pattern implementation

  9. object NoConnectionPoolContext extends ConnectionPoolContext

    No Connection Pool Context

  10. object NoSession extends DBSession with Product with Serializable

    Represents that there is no active session.

  11. object SQL

    SQL abstraction's companion object.

  12. object SQLTemplateParser extends JavaTokenParsers with LogSupport

    SQL Template Parser.

  13. object StatementExecutor extends Serializable

    Companion object

  14. object StringSQLRunner extends Serializable

  15. object ThreadLocalDB

    Thread-local DB.

  16. implicit def convertBigDecimal(bd: BigDecimal): ScalaBigDecimalConverter

  17. implicit def convertJavaSqlDateToConverter(t: Date): UnixTimeInMillisConverter

  18. implicit def convertJavaSqlTimeToConverter(t: Time): UnixTimeInMillisConverter

  19. implicit def convertJavaSqlTimestampToConverter(t: Timestamp): UnixTimeInMillisConverter

  20. implicit def convertJavaUtilDateToConverter(t: Date): UnixTimeInMillisConverter

  21. implicit def convertLocalTimeToConverter(t: LocalTime): LocalTimeConverter

  22. package metadata

  23. def opt[A](v: Any): Option[A]

    scala.Option value converter.

    scala.Option value converter.

    A

    raw type

    v

    nullable raw value

    returns

    optional value

  24. def using[R <: Closable, A](resource: R)(f: (R) ⇒ A): A

Deprecated Value Members

  1. val ExecutableSQLParser: SQLTemplateParser.type

    Annotations
    @deprecated
    Deprecated

    (Since version 1.4.0) ExecutableSQLParser renamed ifself SQLTemplateParser

Inherited from AnyRef

Inherited from Any

Ungrouped