A tidy SQL-based DB access library for Scala developers. This library naturally wraps JDBC APIs and provides you easy-to-use APIs.
Scala Shell Batchfile
Latest commit e9645bd Feb 23, 2017 @xuwei-k xuwei-k committed with seratch update sbt plugins (#639)
Failed to load latest commit information.
notes Update 3.0.0 release note Feb 19, 2017
project update sbt plugins (#639) Feb 23, 2017
sandbox Bump library version of sandbox to 3.0.0-RC1 Feb 12, 2017
scalikejdbc-cli Scala 2.11.8 Mar 30, 2016
scalikejdbc-config use Map#getOrElse Oct 29, 2016
scalikejdbc-core Fix #605 cleanup for merging jsr310 module (#636) Feb 18, 2017
scalikejdbc-interpolation-macro Use xxx.nonEmpty instead of checking `xxx.isEmpty == false` Jul 28, 2016
scalikejdbc-interpolation Fix a typo in docs Jan 7, 2017
scalikejdbc-library Fix #605 cleanup for merging jsr310 module (#636) Feb 18, 2017
scalikejdbc-mapper-generator-core merge scalikejdbc-jsr310 module to scalikejdbc-core Nov 18, 2016
scalikejdbc-mapper-generator Scala 2.12.1 Dec 6, 2016
scalikejdbc-streams Make StreamReadySQL to public (#622) Jan 5, 2017
scalikejdbc-syntax-support-macro add newline at end of file Oct 31, 2016
scalikejdbc-test Add AsyncAutoRollback for ScalaTest AsyncTestSuite (#638) Feb 17, 2017
scripts version 3.0.0-M3 Jan 3, 2017
tools-support/intellij/templates scalikejdbc.SQLInterpolation is deprecated Dec 31, 2014
.gitignore Ignore ensime related files Sep 22, 2016
.travis.yml Scala 2.12.1 Dec 6, 2016
CONTRIBUTING.md fix typo Nov 16, 2016
LICENSE.txt Update copyright Feb 28, 2015
logo.png Updated logo Jun 16, 2014
readme.md Update docs Nov 4, 2016
team-rules.md Update team rule Nov 26, 2016
travis.sh Scala 2.12.1 Dec 6, 2016
travis_before.sh should not execute "git add" multiple times Mar 20, 2015



Just write SQL and get things done!

ScalikeJDBC is a tidy SQL-based DB access library for Scala that naturally wraps JDBC and provides easy-to-use APIs.

ScalikeJDBC is practical and production-ready. Use this library for your real projects.


Build Status Maven Central

Gitter Chat for Casual Q&A

  • English: Gitter
  • 日本語 (Japanese): Gitter

Getting Started

Just add ScalikeJDBC, a JDBC driver, and an slf4j implementation to your sbt build settings:

libraryDependencies ++= Seq(
  "org.scalikejdbc" %% "scalikejdbc"        % "2.5.+",
  "com.h2database"  %  "h2"                 % "1.4.+",
  "ch.qos.logback"  %  "logback-classic"    % "1.1.+"

If you're a Play2 user, take a look at play-support project, too:


First example

After adding the above dependencies to your build.sbt, run sbt console and execute the following code:

import scalikejdbc._

// initialize JDBC driver & connection pool
ConnectionPool.singleton("jdbc:h2:mem:hello", "user", "pass")

// ad-hoc session provider on the REPL
implicit val session = AutoSession

// table creation, you can run DDL statements using #execute as with JDBC
create table members (
  id serial not null primary key,
  name varchar(64),
  created_at timestamp not null

// insert initial data
Seq("Alice", "Bob", "Chris") foreach { name =>
  sql"insert into members (name, created_at) values (${name}, current_timestamp)".update.apply()

// retrieve all data as a List of Map elements
val entities: List[Map[String, Any]] = sql"select * from members".map(_.toMap).list.apply()

// define an entity object and extractor
import org.joda.time._
case class Member(id: Long, name: Option[String], createdAt: DateTime)
object Member extends SQLSyntaxSupport[Member] {
  override val tableName = "members"
  def apply(rs: WrappedResultSet): Member = new Member(
    rs.long("id"), rs.stringOpt("name"), rs.jodaDateTime("created_at"))

// find all Members
val members: List[Member] = sql"select * from members".map(rs => Member(rs)).list.apply()

How did it go? If you'd like to know more details or see more practical examples, see the full documentation at:



Published source code and binary files have the following copyright:

Copyright scalikejdbc.org
Apache License, Version 2.0