org.hibernate.exception.SQLGrammarException: Cannot open connection解决
2012-11-12 15:54
351 查看
环境
MyEclipse 8.6+Hibernate3.2问题
使用Hibernate出现如下错误:
org.hibernate.exception.SQLGrammarException: Cannot open connection at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449) at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167) at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142) at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85) at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1354) at com.el.entities.TestELearning.before(TestELearning.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'el' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.Util.getInstance(Util.java:386) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:951) at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4600) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1328) at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2395) at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2428) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2213) at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:797) at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:389) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305) at java.sql.DriverManager.getConnection(DriverManager.java:582) at java.sql.DriverManager.getConnection(DriverManager.java:154) at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446) ... 21 more org.hibernate.TransactionException: Transaction not successfully started at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:131) at com.el.entities.TestELearning.after(TestELearning.java:54) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:37) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
解决
检查数据库里是否有配置文件中涉及的数据库。
相关文章推荐
- org.hibernate.exception.JDBCConnectionException: Cannot open connection 解决办法
- 解决 org.hibernate.exception.GenericJDBCException: Cannot open connection
- org.hibernate.exception.GenericJDBCException: Cannot open connection
- org.hibernate.exception.JDBCConnectionException: Cannot open connection
- org.hibernate.exception.JDBCConnectionException: Cannot open connection
- org.hibernate.exception.SQLGrammarException: could not insert:XXX解决
- “org.hibernate.exception.SQLGrammarException: could not insert...”解决方法
- org.hibernate.exception.JDBCConnectionException: Cannot open connection
- 数据库被死锁org.hibernate.exception.LockAcquisitionException: Cannot open connection
- org.hibernate.exception.SQLGrammarException:Could not execute JDBC batch update问题的解决
- 大数据查询时出现 org.hibernate.exception.GenericJDBCException: Cannot open connection 请求支援
- org.hibernate.exception.SQLGrammarException:Could not execute JDBC batch update问题的解决
- org.hibernate.exception.SQLGrammarException:Could not execute JDBC batch update问题的解决
- org.hibernate.exception.SQLGrammarException:could not insert:问题解决
- org.hibernate.exception.GenericJDBCException: Could not open connection解决思路 SSH框架
- org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set 解决方法
- org.hibernate.exception.JDBCConnectionException: Cannot open connection
- org.hibernate.exception.SQLGrammarException:Could not execute JDBC batch update问题的解决
- org.hibernate.exception.GenericJDBCException: Cannot open connection
- org.hibernate.exception.GenericJDBCException: Cannot open connection