Skip to content

tototoshi/scalikejdbc-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

scalikejdbc-config

Easy setup for scalikejdbc

This project has been merged to seratch/scalikejdbc.

Example

Working with default database

Connection pool for the database named 'default' can be set up with DBs#setup and closed with DBs#close

db.default.url="jdbc:h2:memory"
db.default.driver="org.h2.Driver"
db.default.user="sa"
db.default.password="secret"
scala> DBs.setup()

scala> DB readOnly { implicit session =>
     |   SQL("SELECT 1 as one").map(rs => rs.int("one")).single.apply()
     | }
res1: Option[Int] = Some(1)

scala> DBs.close()

Working with named databases

src/main/resources/application.conf

db.foo.url="jdbc:h2:memory"
db.foo.driver="org.h2.Driver"
db.foo.user="sa"
db.foo.password="secret"

db.bar.url="jdbc:h2:memory2"
db.bar.driver="org.h2.Driver"
db.bar.user="sa2"
db.bar.password="secret2"
scala> import com.github.tototoshi.scalikejdbc.config._

scala> import scalikejdbc._

scala> DBs.setupAll

scala> NamedDB('foo) readOnly { implicit session =>
     |   SQL("SELECT 1 as one").map(rs => rs.int("one")).single.apply()
     | }
res0: Option[Int] = Some(1)

scala> NamedDB('bar) readOnly { implicit session =>
     |   SQL("SELECT 1 as one").map(rs => rs.int("one")).single.apply()
     | }
res1: Option[Int] = Some(1)

scala> DBs.closeAll

About

Easy setup for scalikejdbc

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages