On this fine blog it says that in dbconsole I should be able to see little icons on the left for my tables like how he sees "BOOK". http://www.redtoad.ca/ataylor/2011/11/h2-database-console-in-grails-2/
I'm using STS and grails 2.0, and I make an application with several domain classes (I can go to the controllers and see lists and stuff), but the dbconsole doesn't show any domain classes. Just goes straight into INFORMATION_SCHEMA
.
Where are my domain classes? I can see lists and use .findBy and stuff!!
You need to change the URL to what it says in your DataSource.groovy
URL should be changed in this initial screen.
Thank you, Mikey! I had the same problem! Indeed, look into
grails-app/conf/DataSource.groovy
At least in my case, JDBC URL can be set to jdbc:h2:mem:devDb for the development database, jdbc:h2:mem:testDb
for the test database, and jdbc:h2:mem:prodDb
for the production database.
The console has no way of knowing which one you prefer, so it defaults to test. Also, if you click on "JDBC URL" in the dbconsole mode in the browser, it shows you some tips. In particular, it explains that "The URL jdbc:h2:~/test means the database is stored in the user home directory in files starting with 'test'." Indeed, in my home directory I now have test.h2.db
, test.lock.db
, and test.trace.db
. It also explains why the data is not persisted by default. Didn't you notice that with the default setup every time you restart Grails, you have to re-create all the objects? Well, this is because of the ":mem:" part in the JDBC URL.
This default probably has nothing to do with Grails; I would guess that H2 simply creates a test database in your home directory by default, unless otherwise stated. I would also imagine that you may have many different databases in a complicated production environment, and this is why Grails is not trying to guess what it is that you want.
Also see the official H2 documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With