Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think the problem is that the database is getting locked. Let's try this one then (works on my experiment):</p> <p>edit your grails-app/conf/spring/resources.groovy and make it looking like this:</p> <pre><code>// Place your Spring DSL code here beans = { h2Server(org.h2.tools.Server, "-tcp,-tcpPort,8043") { bean -&gt; bean.factoryMethod = "createTcpServer" bean.initMethod = "start" bean.destroyMethod = "stop" } } </code></pre> <p>Then, modify your grails-app/conf/DataSource.groovy to look like this:</p> <pre><code>test { dataSource { dbCreate = "update" url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000" } } </code></pre> <p>Now, you are ready to add some new objects as per the tutorial:</p> <pre><code>$ grails grails&gt; run-app grails&gt; shell groovy:000&gt; new test.Book(title: 'Book 1').save(failOnError: true) ===&gt; test.Book : 1 groovy:000&gt; new test.Book(title: 'Book 2').save(failOnError: true) ===&gt; test.Book : 2 groovy:000&gt; test.Book.list() ===&gt; [test.Book : 1, test.Book : 2] </code></pre> <p>To view the H2 console, go to </p> <pre><code>http://localhost:8080/{project}/dbconsole </code></pre> <p>but select [Generic H2 Server] from the list and on the JDBC URL enter: </p> <pre><code>jdbc:h2:tcp://localhost:8043/mem:devDb </code></pre> <p>and connect. I hope that helps</p> <p>======================</p> <p>After a bit further experimentation, it appears that locking was your problem and you need to use a mixed mode approach when connecting to your H2. You can read more information here:</p> <p><a href="http://www.h2database.com/html/features.html#auto_mixed_mode">http://www.h2database.com/html/features.html#auto_mixed_mode</a></p> <p>So, the simplest thing to do is use this jdbc connection URL:</p> <pre><code>url = "jdbc:h2:/tmp/myDB;MVCC=TRUE;LOCK_TIMEOUT=10000;AUTO_SERVER=TRUE" </code></pre> <p>for both your application and the H2 dbconsole (notice the AUTO_SERVER=TRUE) (no need to modify the spring bean)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload