Skip to content

Instantly share code, notes, and snippets.

Created March 17, 2015 06:53
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save maji-KY/646f202cacac855cd8da to your computer and use it in GitHub Desktop.
sample JDBI with hikariCP
package com.neco_labo.db
import com.zaxxer.hikari.{HikariDataSource, HikariConfig}
import org.skife.jdbi.v2.{DefaultMapper, DBI}
import scala.collection.JavaConverters._
object JDBI extends App {
val config = new HikariConfig()
config.addDataSourceProperty("dataSourceClassName", "com.mysql.jdbc.jdbc2.optional.MysqlDataSource")
config.addDataSourceProperty("autoCommit", "false")
config.addDataSourceProperty("useServerPrepStmts", "true")
config.addDataSourceProperty("cachePrepStmts", "true")
val ds = new HikariDataSource(config)
val dbi = new DBI(ds)
val h =
val result = h.createQuery("select * from table")
.map(new DefaultMapper)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment