I’m working through a Grails tutorial and trying to switch my database from HSQLDB to MySQL. I’m using Grails version 1.2.1 and have updated my DataSource.groovy file to configure MySQL settings.
Here’s my current DataSource.groovy configuration:
dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
url = "jdbc:mysql://localhost/bookstore"
dbCreate = "create"
username = "bookapp"
password = "bookapp"
dialect = org.hibernate.dialect.MySQL5InnoDBDialect
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
}
environments {
development {
}
test {
}
production {
}
}
The application starts without errors when I run grails run-app, but when I try to access any page that hits the database, I encounter this error:
java.sql.SQLException: Table not found in statement [select this_.id as id1_0_, this_.version as version1_0_, this_.name as name1_0_, this_.category as category1_0_ from book this_ limit ?]
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
at bookstore.BookController$_closure1.doCall(script1269434425504953491149.groovy:8)
The error clearly indicates that it’s still trying to use HSQLDB. My MySQL database remains empty with no tables created.
I’ve already tried:
- Adding the MySQL connector JAR to the lib folder
- Running
grails clean - Moving the dataSource config into the development environment block
Why does Grails keep using HSQLDB despite my MySQL configuration?