2012-07-05 56 views
-1

我有一个亚马逊的Ec2的MySQL实例(RDS)。它有一个名为locker的数据库。我可以从我的终端通过以下步骤从here访问它。为什么我会收到未知的数据库错误?

我已经配置我的DataSource.groovy为:

development { 
     dataSource { 
      dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', '' 
      url = "jdbc:mysql://localhost/locker?useUnicode=yes&characterEncoding=UTF-8" 
      username = "root" 
      password = "" 
     } 
    } 

当我运行grails run-app,我得到以下错误:

| Error 2012-07-05 23:15:23,818 [Thread-9] ERROR context.GrailsContextLoader - Error executing bootstraps: 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 PoolableConnectionFactory (Unknown database 'locker') 
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 PoolableConnectionFactory (Unknown database 'locker') 
    Line | Method 
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 166 | run  in java.util.concurrent.FutureTask 
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor 
| 603 | run  in java.util.concurrent.ThreadPoolExecutor$Worker 
^ 679 | 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 PoolableConnectionFactory (Unknown database 'locker') 
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 166 | run  in java.util.concurrent.FutureTask 
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor 
| 603 | run  in java.util.concurrent.ThreadPoolExecutor$Worker 
^ 679 | 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 PoolableConnectionFactory (Unknown database 'locker') 
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 166 | run  in java.util.concurrent.FutureTask 
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor 
| 603 | run  in java.util.concurrent.ThreadPoolExecutor$Worker 
^ 679 | 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 PoolableConnectionFactory (Unknown database 'locker') 
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 166 | run  in java.util.concurrent.FutureTask 
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor 
| 603 | run  in java.util.concurrent.ThreadPoolExecutor$Worker 
^ 679 | 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 PoolableConnectionFactory (Unknown database 'locker') 
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 166 | run  in java.util.concurrent.FutureTask 
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor 
| 603 | run  in java.util.concurrent.ThreadPoolExecutor$Worker 
^ 679 | run . . . in java.lang.Thread 

Caused by MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Unknown database 'locker') 
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 166 | run  in java.util.concurrent.FutureTask 
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor 
| 603 | run  in java.util.concurrent.ThreadPoolExecutor$Worker 
^ 679 | run . . . in java.lang.Thread 

Caused by SQLNestedException: Cannot create PoolableConnectionFactory (Unknown database 'locker') 
->> 1549 | createPoolableConnectionFactory in org.apache.commons.dbcp.BasicDataSource 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 1388 | createDataSource in  '' 
| 1044 | getConnection in  '' 
| 334 | innerRun in java.util.concurrent.FutureTask$Sync 
| 166 | run . . . in java.util.concurrent.FutureTask 
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor 
| 603 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker 
^ 679 | run  in java.lang.Thread 

Caused by MySQLSyntaxErrorException: Unknown database 'locker' 
->> 411 | handleNewInstance in com.mysql.jdbc.Util 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 386 | getInstance in  '' 
| 1052 | createSQLException in com.mysql.jdbc.SQLError 
| 3597 | checkErrorPacket in com.mysql.jdbc.MysqlIO 
| 3529 | checkErrorPacket in  '' 
| 935 | checkErrorPacket in  '' 
| 4101 | secureAuth411 in  '' 
| 1300 | doHandshake in  '' 
| 2337 | coreConnect in com.mysql.jdbc.ConnectionImpl 
| 2370 | connectOneTryOnly in  '' 
| 2154 | createNewIO in  '' 
| 792 | <init> in  '' 
|  47 | <init> . in com.mysql.jdbc.JDBC4Connection 
| 411 | handleNewInstance in com.mysql.jdbc.Util 
| 381 | getInstance in com.mysql.jdbc.ConnectionImpl 
| 305 | connect in com.mysql.jdbc.NonRegisteringDriver 
|  38 | createConnection in org.apache.commons.dbcp.DriverConnectionFactory 
| 582 | makeObject in org.apache.commons.dbcp.PoolableConnectionFactory 
| 1556 | validateConnectionFactory in org.apache.commons.dbcp.BasicDataSource 
| 1545 | createPoolableConnectionFactory in  '' 
| 1388 | createDataSource in  '' 
| 1044 | getConnection in  '' 
| 334 | innerRun in java.util.concurrent.FutureTask$Sync 
| 166 | run  in java.util.concurrent.FutureTask 
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor 
| 603 | run  in java.util.concurrent.ThreadPoolExecutor$Worker 
^ 679 | run . . . in java.lang.Thread 

但是,当我从locker更改数据库testing(其它数据库,我已经创建),一切都很好,我的grails应用程序正在运行。

为什么它不在第一种情况下运行?

回答

1

无论出于何种原因,当您的应用程序连接,它不能够“看到”的“更衣室”数据库:

Unknown database 'locker' 

这可能是某种权限问题的MySQL中涉及到什么数据库你有权连接的用户。

当然,这是假定了“更衣室”数据库确实实际存在要连接到的数据库,(基于该连接字符串)是localhost,而不是一个RDS运行MySQL服务器上。

+0

哦!那么你的意思是我将无法在我的Grails应用程序中访问'rds'数据库? – batman 2012-07-06 03:59:03

+0

不,我是说a。)如果您尝试连接到rds实例,那么您使用了错误的连接字符串; b。)您必须确保您所连接的数据库存在于您所在的服务器上连接到。 – cdeszaq 2012-07-06 13:45:57

相关问题