Hibernate框架:org.hibernate.exception.SQLGrammarException: Cannot open connection   at org.hibernate...

2018/08/08 07:32
阅读数 78

报错信息

org.hibernate.exception.SQLGrammarException: Cannot open connection at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java92)

报错原因

在数据库中没有对应的配置文件的数据库名称

解决方法

创建或者修改正确的数据库名称即可

报错信息

Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
 1 java.lang.ExceptionInInitializerError
 2     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 3     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 4     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 5     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
 6     at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)
 7     at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
 8     at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
 9     at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
10     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
11     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
12     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
13     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
14     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
15     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
16     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
17     at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
18     at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
19     at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
20     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
21     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
22     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
23     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
24 Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
25     at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:110)
26     at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:135)
27     at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:80)
28     at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:323)
29     at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:475)
30     at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:133)
31     at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
32     at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:297)
33     at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1385)
34     at com.mikey.util.HibernateUtil.<clinit>(HibernateUtil.java:11)
35     ... 22 more
36 Caused by: java.lang.reflect.InvocationTargetException
37     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
38     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
39     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
40     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
41     at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:107)
42     ... 31 more
43 Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for students in class com.mikey.bean.Classs
44     at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:328)
45     at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:321)
46     at org.hibernate.mapping.Property.getGetter(Property.java:304)
47     at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:299)
48     at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:158)
49     at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:77)
50     ... 36 more
errorMessage

报错原因

在映射文件和持久化类的配置不正确,请检查修改配置参数 

解决方法

检查持久化类的映射文件配置参数

 

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部