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"


FWIW, if you need to connect to MySQL using MAMP (or WAMP), here’s that driver and URL information, circa June, 2020:


Just change the database name, username, and password to match your system. Also, your MySQL URL might not require those extra parameters on the end.