NanoNi
NanoNi

Reputation: 335

DataSource.groovy error

I am pretty new to Grails and am trying to learn things from the 'Grails in Action' book. I have this example which asks to change the dataSource url in the DataSource.groovy file and when I do that I get an error. Here are the changes and the error. Can anyone help me out? Thanks in advance,

previous:

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

After Change:

dataSource {
        dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
        url = "jdbc:hsqldb:file:devDB;shutdown=true"

Error:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': 
    Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: 
    Error creating bean with name 'transactionManager': 
      Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException:
    Error creating bean with name 'sessionFactory':
      Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException:
    Error creating bean with name 'hibernateProperties':
      Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException:
    Error creating bean with name 'dialectDetector':
      Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException:
    Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: 
    Cannot create JDBC driver of class 'org.h2.Driver' for connect URL 'jdbc:hsqldb:file:devDB;shutdown=true' (Use --stacktrace to see the full trace)

Upvotes: 0

Views: 410

Answers (1)

Sergei Shushkevich
Sergei Shushkevich

Reputation: 1376

You've changed H2 to HSQLDB - you need to add corresponding dependency to BuildConfig.groovy:

dependencies {
    runtime 'hsqldb:hsqldb:1.8.0.10'
}

Also use the following driver in DataSource.groovy:

driverClassName = "org.hsqldb.jdbcDriver" 

Upvotes: 3

Related Questions