Reputation: 10795
I have a really simple domain class
class Person {
String code
}
And I am also using default DataSource configuration:
dataSource {
pooled = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
dialect = "org.hibernate.dialect.H2Dialect"
}
} ...
But when I open /dbconsole then I see that DB is empty and there is no tables. Why? What I am doing wrong?
Upvotes: 2
Views: 1956
Reputation: 5538
When you open the dbconsole
you have to make sure its reading the correct database.
In your url section, point the dbconsole to the url that your app is using. In your case:
jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000
Upvotes: 6
Reputation: 3190
If you are running Grails in development mode and make changes I believe they will not be committed to the H2 database if the default settings are in place. You would need to run the app in production mode or change some configuration properties to view the updated information in DBConsole.
Similar StackOverflow Question
Upvotes: 0
Reputation: 54
My project i am using mysql and my datasource looks like
dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
loggingSql = false
properties {
validationQuery="select 1"
testWhileIdle=true
timeBetweenEvictionRunsMillis=60000
}
}
hibernate {
cache.use_second_level_cache = false
cache.use_query_cache = false
cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
generate_statistics = false
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop','update'
url="jdbc:mysql://localhost:3306/my_db"
username="XXX"
password="XXXXXX"
}
}
}
And this configuration is working fine
Upvotes: 0