scalikejdbc

package scalikejdbc

ScalikeJDBC - A thin JDBC wrapper in Scala

Just write SQL:

This is a thin JDBC wrapper library which just uses java.sql.PreparedStatement internally. Users only need to write SQL and map from java.sql.ResultSet objects to Scala objects. It's pretty simple, really.

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 user 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 user 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 user 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 TooManyRowsException(expected: Int, actual: Int) extends Exception with Product with Serializable

    Exception which represents too many rows returned.

  30. class Tx extends AnyRef

    DB Transaction abstraction.

  31. class UnixTimeInMillisConverter extends AnyRef

    Unix Time Converter to several types.

  32. sealed trait WithExtractor extends AnyRef

    Represents an extractor is already specified or not

  33. 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 ExecutableSQLParser extends JavaTokenParsers with LogSupport

    ExecutableSQL Parser.

  7. object GeneralizedTypeConstraintsForWithExtractor

    Generalized type constraints for WithExtractor

  8. object GlobalSettings

    GlobalSettings for this library

  9. object LoanPattern

    Loan pattern implementation

  10. object NoConnectionPoolContext extends ConnectionPoolContext

    No Connection Pool Context

  11. object NoSession extends DBSession with Product with Serializable

    Represents that there is no active session.

  12. object SQL

    SQL abstraction's companion object.

  13. object ThreadLocalDB

    Thread-local DB.

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

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

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

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

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

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

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

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

Inherited from AnyRef

Inherited from Any

No Group