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. case class IllegalRelationshipException(message: String) extends IllegalStateException with Product with Serializable

    Exception which represents that an illegal relationship is found.

  12. case class InvalidColumnNameException(name: String) extends Exception with Product with Serializable

    Exception which represents invalid key is specified.

  13. case class JDBCSettings(url: String, user: String, password: String, driverName: String) extends Product with Serializable

    JDBC Settings

  14. class LocalTimeConverter extends AnyRef

    org.joda.time.LocalTime converter.

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

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

    Multiple connection pool context

  17. case class NameBindingSQLValidatorSettings(ignoredParams: IgnoredParamsValidation = ...) extends Product with Serializable

    Settings for Name binding SQL validator

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

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

    Named Basic DB Accessor

  20. trait NoExtractor extends WithExtractor

    Represents that this SQL doesn't have an extractor yet

  21. class OneToManies2SQL[A, B1, B2, E <: WithExtractor, Z] extends SQL[Z, E]

  22. class OneToManies2SQLToList[A, B1, B2, E <: WithExtractor, Z] extends SQLToList[Z, E] with OneToManies2Extractor[A, B1, B2, E, Z]

  23. class OneToManies2SQLToOption[A, B1, B2, E <: WithExtractor, Z] extends SQLToOption[Z, E] with OneToManies2Extractor[A, B1, B2, E, Z]

  24. class OneToManies2SQLToTraversable[A, B1, B2, E <: WithExtractor, Z] extends SQLToTraversable[Z, E] with OneToManies2Extractor[A, B1, B2, E, Z]

  25. class OneToManies3SQL[A, B1, B2, B3, E <: WithExtractor, Z] extends SQL[Z, E]

  26. class OneToManies3SQLToList[A, B1, B2, B3, E <: WithExtractor, Z] extends SQLToList[Z, E] with OneToManies3Extractor[A, B1, B2, B3, E, Z]

  27. class OneToManies3SQLToOption[A, B1, B2, B3, E <: WithExtractor, Z] extends SQLToOption[Z, E] with OneToManies3Extractor[A, B1, B2, B3, E, Z]

  28. class OneToManies3SQLToTraversable[A, B1, B2, B3, E <: WithExtractor, Z] extends SQLToTraversable[Z, E] with OneToManies3Extractor[A, B1, B2, B3, E, Z]

  29. class OneToManies4SQL[A, B1, B2, B3, B4, E <: WithExtractor, Z] extends SQL[Z, E]

  30. class OneToManies4SQLToList[A, B1, B2, B3, B4, E <: WithExtractor, Z] extends SQLToList[Z, E] with OneToManies4Extractor[A, B1, B2, B3, B4, E, Z]

  31. class OneToManies4SQLToOption[A, B1, B2, B3, B4, E <: WithExtractor, Z] extends SQLToOption[Z, E] with OneToManies4Extractor[A, B1, B2, B3, B4, E, Z]

  32. class OneToManies4SQLToTraversable[A, B1, B2, B3, B4, E <: WithExtractor, Z] extends SQLToTraversable[Z, E] with OneToManies4Extractor[A, B1, B2, B3, B4, E, Z]

  33. class OneToManies5SQL[A, B1, B2, B3, B4, B5, E <: WithExtractor, Z] extends SQL[Z, E]

  34. class OneToManies5SQLToList[A, B1, B2, B3, B4, B5, E <: WithExtractor, Z] extends SQLToList[Z, E] with OneToManies5Extractor[A, B1, B2, B3, B4, B5, E, Z]

  35. class OneToManies5SQLToOption[A, B1, B2, B3, B4, B5, E <: WithExtractor, Z] extends SQLToOption[Z, E] with OneToManies5Extractor[A, B1, B2, B3, B4, B5, E, Z]

  36. class OneToManies5SQLToTraversable[A, B1, B2, B3, B4, B5, E <: WithExtractor, Z] extends SQLToTraversable[Z, E] with OneToManies5Extractor[A, B1, B2, B3, B4, B5, E, Z]

  37. class OneToManySQL[A, B, E <: WithExtractor, Z] extends SQL[Z, E]

  38. class OneToManySQLToList[A, B, E <: WithExtractor, Z] extends SQLToList[Z, E] with OneToManyExtractor[A, B, E, Z]

  39. class OneToManySQLToOption[A, B, E <: WithExtractor, Z] extends SQLToOption[Z, E] with OneToManyExtractor[A, B, E, Z]

  40. class OneToManySQLToTraversable[A, B, E <: WithExtractor, Z] extends SQLToTraversable[Z, E] with OneToManyExtractor[A, B, E, Z]

  41. class OneToOneSQL[A, B, E <: WithExtractor, Z] extends SQL[Z, E]

  42. class OneToOneSQLToList[A, B, E <: WithExtractor, Z] extends SQLToList[Z, E] with OneToOneExtractor[A, B, E, Z]

  43. class OneToOneSQLToOption[A, B, E <: WithExtractor, Z] extends SQLToOption[Z, E] with OneToOneExtractor[A, B, E, Z]

  44. class OneToOneSQLToTraversable[A, B, E <: WithExtractor, Z] extends SQLToTraversable[Z, E] with OneToOneExtractor[A, B, E, Z]

  45. class OneToXSQL[A, E <: WithExtractor, Z] extends SQL[Z, E]

  46. class ResultSetCursor extends AnyRef

    java.sql.ResultSet cursor

  47. case class ResultSetExtractorException(message: String) extends IllegalArgumentException with Product with Serializable

    Exception which represents failure on ResultSet extraction.

  48. class ResultSetTraversable extends Traversable[WrappedResultSet]

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

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

    SQL abstraction.

  50. class SQLBatch extends AnyRef

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

  51. class SQLExecution extends AnyRef

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

  52. trait SQLFormatter extends AnyRef

    SQL formatter

  53. case class SQLFormatterSettings(formatterClassName: Option[String]) extends LogSupport with Product with Serializable

    Settings for SQL formatter

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

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

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

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

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

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

  57. class SQLUpdate extends AnyRef

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

  58. class SQLUpdateWithGeneratedKey extends AnyRef

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

  59. class ScalaBigDecimalConverter extends AnyRef

    BigDecimal converter.

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

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

    String SQL Runner

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

    Exception which represents too many rows returned.

  63. class Tx extends AnyRef

    DB Transaction abstraction.

  64. class UnixTimeInMillisConverter extends AnyRef

    Unix Time Converter to several types.

  65. sealed trait WithExtractor extends AnyRef

    Represents an extractor is already specified or not

  66. 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 OneToXSQL

  12. object SQL

    SQL abstraction's companion object.

  13. object SQLFormatterSettings extends Serializable

  14. object SQLTemplateParser extends JavaTokenParsers with LogSupport

    SQL Template Parser.

  15. object StatementExecutor extends Serializable

    Companion object

  16. object StringSQLRunner extends Serializable

  17. object ThreadLocalDB

    Thread-local DB.

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

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

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

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

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

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

  24. package globalsettings

  25. package metadata

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

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