2013-02-26 158 views
0

我试图将我的grails应用程序连接到本地运行的DB2数据库。当我想启动我的应用程序时,我得到多个错误?我只着手Grails,甚至更多地介绍DB2数据库管理。有人可以帮我吗 ?将Grails连接到DB2数据库

这里的误差落后

Message: 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:db2://localhost:50000/DTH3_E:currentSchema=DFP_V115' 
    Line | Method 
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 138 | run  in java.util.concurrent.FutureTask 
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker 
| 908 | run  in  '' 
^ 662 | run . . in java.lang.Thread 
Caused by 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:db2://localhost:50000/DTH3_E:currentSchema=DFP_V115' 
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 138 | run  in java.util.concurrent.FutureTask 
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker 
| 908 | run  in  '' 
^ 662 | run . . in java.lang.Thread 
Caused by 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:db2://localhost:50000/DTH3_E:currentSchema=DFP_V115' 
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 138 | run  in java.util.concurrent.FutureTask 
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker 
| 908 | run  in  '' 
^ 662 | run . . in java.lang.Thread 
Caused by 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:db2://localhost:50000/DTH3_E:currentSchema=DFP_V115' 
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 138 | run  in java.util.concurrent.FutureTask 
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker 
| 908 | run  in  '' 
^ 662 | run . . in java.lang.Thread 
Caused by 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:db2://localhost:50000/DTH3_E:currentSchema=DFP_V115' 
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 138 | run  in java.util.concurrent.FutureTask 
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker 
| 908 | run  in  '' 
^ 662 | run . . in java.lang.Thread 
Caused by 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:db2://localhost:50000/DTH3_E:currentSchema=DFP_V115' 
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 138 | run  in java.util.concurrent.FutureTask 
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker 
| 908 | run  in  '' 
^ 662 | run . . in java.lang.Thread 
Caused by SQLNestedException: Cannot create JDBC driver of class 'org.h2.Driver' for connect URL 'jdbc:db2://localhost:50000/DTH3_E:currentSchema=DFP_V115' 
->> 1452 | createConnectionFactory in org.apache.commons.dbcp.BasicDataSource 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 1371 | createDataSource in  '' 
| 1044 | getConnection in  '' 
| 303 | innerRun in java.util.concurrent.FutureTask$Sync 
| 138 | run . . in java.util.concurrent.FutureTask 
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker 
| 908 | run . . in  '' 
^ 662 | run  in java.lang.Thread 
Caused by SQLException: No suitable driver 
->> 264 | getDriver in java.sql.DriverManager 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 1437 | createConnectionFactory in org.apache.commons.dbcp.BasicDataSource 
| 1371 | createDataSource in  '' 
| 1044 | getConnection in  '' 
| 303 | innerRun in java.util.concurrent.FutureTask$Sync 
| 138 | run  in java.util.concurrent.FutureTask 
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker 
| 908 | run  in  '' 
^ 662 | run . . in java.lang.Thread 

,在我的DataSource.groovy文件中,这是我改变了:

environments { 
    development { 
     dataSource { 
      dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', '' 
      //url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000" 
      url = "jdbc:db2://localhost:50000/DTH3_E:currentSchema=DFP_V115" 
     } 
    } 
.... 

有了一些研究,我理解,这是我的休眠配置。任何人都可以验证吗?接下来我该去哪里......相当丢失说至少

如果想知道,数据库已启动并运行,我可以使用DbVisualizer连接到它。

在此先感谢您的帮助!如果需要更多细节,请问:)我会尽量澄清问题。

回答

3

从您的异常中,Grails正尝试使用H2 JDBC驱动程序连接到您的DB2数据库。尝试指定DB2 Hibernate的方言在dataSource声明,看它是否会使用正确的驱动程序:

dataSource { 
    dialect="org.hibernate.dialect.DB2Dialect" 
} 

另外,还要确保你有必要的DB2罐子在你Grails项目。

+0

感谢您的提示...进入另一个问题,我想这是因为用户没有数据库的所有权利。在DB2中,您知道如何授予用户所有权限?我在本地使用数据库,所以不要紧,如果我搞砸了一些东西(用户名:dthdbusr) – kanadianDri3 2013-02-27 09:09:20

+0

对不起。我从来没有使用DB2,所以我无法提供用户权限。 – schmolly159 2013-02-27 16:53:22