0
votes

I am trying to create database using h2, i did a run for it and connect to Generic H2 (Server) with the following sittings

Driver Class: org.h2.jdbcx.JdbcDataSource

JDBC URL: jdbc:h2:mem:MyDB

username : sa

password : sa

and this is my code to use it

package MainPac
import io.getquill._
object DataBaseService  extends App {
  lazy val ctx = new H2JdbcContext(SnakeCase, "db")
  case class TEST(ID:Int,NAME :String)

  import ctx._
  var thisistest= quote {
    query[TEST].map( r => r.NAME)
  }
   ctx.run(thisistest)
}

and in config file

 `db {
 dataSourceClassName : "org.h2.jdbcx.JdbcDataSource"
 dataSource.url : "jdbc:h2:mem:MyDB;IFEXISTS=TRUE;DB_CLOSE_DELAY=-1"
 dataSource.user : "sa"
}
`
1

1 Answers

0
votes

context definition

lazy val ctx = new H2JdbcContext(SnakeCase, "ctx")

application.properties

ctx.dataSourceClassName=org.h2.jdbcx.JdbcDataSource
ctx.dataSource.url=jdbc:h2:mem:yourdbname
ctx.dataSource.user=sa

Try yourdbname lower case.