2013-02-26 157 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