A ScalikeJdbc SQL SELECT example with JDBC-style parameters

Here’s another ScalikeJdbc SQL SELECT example. If I remember right, this one doesn’t rely on a configuration file, it just uses the JDBC parameters shown:

import scalikejdbc._

object ScalikeJdbc1Query extends App {

    // initialize JDBC driver & connection pool
    Class.forName("org.h2.Driver")
    ConnectionPool.singleton("jdbc:h2:./test", "sa", "sa")

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

    // for now, retrieves all data as Map value
    val entities: List[Map[String, Any]] = sql"select * from users"
        .map(_.toMap)
        .list
        .apply()
    entities.foreach(println)

}