Error executing DDL via JDBC Statement

转自:http://www.cnblogs.com/jinjiyese153/p/6902859.html

1.问题描述:

  启动hibernate测试案例时报错如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement
     at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java: 67 )
     at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java: 438 )
     at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java: 423 )
     at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java: 314 )
     at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java: 165 )
     at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java: 134 )
     at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java: 120 )
     at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java: 148 )
     at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java: 65 )
     at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java: 459 )
     at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java: 465 )
     at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java: 711 )
     at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java: 727 )
     at org.hibernate.test.StudentTest.before(StudentTest.java: 32 )
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 57 )
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 43 )
     at java.lang.reflect.Method.invoke(Method.java: 606 )
     at org.junit.runners.model.FrameworkMethod$ 1 .runReflectiveCall(FrameworkMethod.java: 50 )
     at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java: 12 )
     at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java: 47 )
     at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java: 24 )
     at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java: 27 )
     at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java: 325 )
     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java: 78 )
     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java: 57 )
     at org.junit.runners.ParentRunner$ 3 .run(ParentRunner.java: 290 )
     at org.junit.runners.ParentRunner$ 1 .schedule(ParentRunner.java: 71 )
     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java: 288 )
     at org.junit.runners.ParentRunner.access$ 000 (ParentRunner.java: 58 )
     at org.junit.runners.ParentRunner$ 2 .evaluate(ParentRunner.java: 268 )
     at org.junit.runners.ParentRunner.run(ParentRunner.java: 363 )
     at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java: 86 )
     at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java: 38 )
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java: 459 )
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java: 675 )
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java: 382 )
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java: 192 )
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB' at line 8
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java: 57 )
     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java: 45 )
     at java.lang.reflect.Constructor.newInstance(Constructor.java: 526 )
     at com.mysql.jdbc.Util.handleNewInstance(Util.java: 425 )
     at com.mysql.jdbc.Util.getInstance(Util.java: 408 )
     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java: 943 )
     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java: 3973 )
     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java: 3909 )
     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java: 2527 )
     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java: 2680 )
     at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java: 2486 )
     at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java: 2444 )
     at com.mysql.jdbc.StatementImpl.executeInternal(StatementImpl.java: 845 )
     at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java: 745 )
     at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java: 54 )
     ... 37 more

2.解决方案:

  因为hibernate设置的方言为

1
org.hibernate.dialect.MySQLInnoDBDialect

  该方言建表使用的是MySQL5.0之前的“type=InnoDB”SQL语句,但是使用的MySQL版本为5.7.17,“type=InnoDB”不再生效,变为了“ENGINE=InnoDB”

  因此需要将方言设置为

1
org.hibernate.dialect.MySQL5InnoDBDialect

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值