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
    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"


Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.