0

I am working on a grails project and trying to use H2 in-memory database to temporarily save the data coming from the user input. I have added this code: url = "jdbc:h2:memory" in my datasource to set up my database. I created Domain Class that contains two properties. By running the dbconsole in my browser, I am able to browse the database I have created, and the table (which corresponds to the class name). I am using the ClassName.save(flush:true) to save the data in the in-memory database, but this throws an error, 'No property "database property name" of "class name" is found', and when I check the database in the console, nothing is saved.

Am I missing something? Please help.

tim_yates
  • 167,322
  • 27
  • 342
  • 338
chemilleX3
  • 1,176
  • 5
  • 17
  • 27
  • Be aware the in-memory database is discarded, by default, when the connection closes. You can override this behavior. See: [*Keep H2 in-memory database between connections*](https://dba.stackexchange.com/q/224338/19079) and [*H2 in-memory database. Table not found*](https://stackoverflow.com/q/5763747/642706) – Basil Bourque Dec 06 '18 at 21:27

1 Answers1

2

In my project the configuration string looks different:

dataSource {
    dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
    url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
}

I believe, you have wrong the "memory" and you are missing the database name (last part of the JDBC string before ";"). Under this string you can also connect to the database via "dbconsole".

Tom Metz
  • 919
  • 6
  • 7