Error executing DDL via JDBC Statement

? 版权声明:本文为博主原创文章,转载请注明出处

1.问题描述:

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

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设置的方言为

org.hibernate.dialect.MySQLInnoDBDialect

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

  因此需要将方言设置为

org.hibernate.dialect.MySQL5InnoDBDialect

时间: 2024-10-13 03:35:07

Error executing DDL via JDBC Statement的相关文章

Error executing DDL &quot;drop sequence if exists hibernate_sequence&quot; via JDBC Statement

Error executing DDL "drop sequence if exists hibernate_sequence" via JDBC Statement 在使用springboot+jpa进行部署项目时候, 因为application.yml文件配置错误,所以出现上面的异常情况.然后修改.yml配置文件为: spring: jpa: show-sql: true hibernate: ddl-auto: update database-platform: org.hibe

关于Error executing aapt的问题

这两天装了ubuntu 14.0.4系统,在这个系统上装了eclipse的android开发环境.原以为一切顺利,结果开发环境装完导入工程后,工程提示有红叉. R文件不能自动生成,按R文件不能自动生成的方法去解决,根本不是这些原因. 查看problem发现提示: Error executing aapt. Please check aapt is present at xxxxx 找了很多资料也没有搞定.后来在stackoverflow上有人说可能是需要  lib32z1 lib32ncurse

【ERROR】---Error executing &quot;adb devices&quot;:ADB server didn&#39;t ACK

搭建环境 ionic emulate android 的时候出现问题 端口占用,找到占用端口的程序,结束进程再启动 重新ionic emulate android 还是报错,闪了一下说failed to execute tools android.bat 直接运行AVD Manger.exe 报错,failed to execute tools android.bat 拷贝AVD Manager.exe至D:\android-sdk-windows\sdk目录下 [ERROR]---Error

Java-解决SSH集成时,oracle报错:Error while registering Oracle JDBC Diagnosablility MBean

今天在做项目练习时,在集成SSH后,发现控制台有oracle的报错: Error while registering Oracle JDBC Diagnosability MBean. javax.management.MalformedObjectNameException: Invalid character ' ' in value part of property at javax.management.ObjectName.construct(ObjectName.java:602)

nagios &nbsp; IO监控 Error executing iostat command

本来io监控是好好的,昨天因为要装postfix,就卸载以前sendmail,yum remove sendmail.今天来打开nagios一开,io的监控成灰色的了.报错如下:IOSTAT UNKNOWN - Error executing iostat command 郁闷了别的都好好的.于我就去该机器下面手动执行一下. cd /usr/local/nagios/libexec/ [[email protected] libexec]# ./check_iostat Can't exec "

ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] - Data truncation: Incorrect datetime value: &#39;&#39; for column &#39;pubdate&#39; at row 1

之前的Connector/J版本是:mysql-connector-java-5.0.4-bin.jar 后来换成mysql-connector-java-5.1.45-bin.jar,问题解决 2018-02-16 01:07:10,086 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] - SQL Error: 0, SQLState: 220012018-02-16 01:07:10,086 ERROR [org.hibern

JDBC Statement PreparedStatement CallableStatement

在 JDBC 应用程序中,JDBC 语句对象用于将 SQL 语句发送到数据库服务器.一个语句对象与一个连接相关联,应用程序与数据库服务器之间的通信由语句对象来处理. JDBC 中有三种类型的语句对象: 1. 常规语句(General statement) 2. 预置语句(Prepared statement) 3. 可调用语句(Callable statement) 语句对象与一个连接相关联,所以要创建一个语句对象,首先应该建立一个数据库连接.连接的获取见上一篇博客. 关于这三种语句,个人觉得最

JDBC Statement对象执行批量处理实例

以下是使用Statement对象的批处理的典型步骤序列 - 使用createStatement()方法创建Statement对象. 使用setAutoCommit()将自动提交设置为false. 使用addBatch()方法在创建的Statement对象上添加SQL语句到批处理中. 在创建的Statement对象上使用executeBatch()方法执行所有SQL语句. 最后,使用commit()方法提交所有更改. 此示例代码是基于前面章节中完成的环境和数据库设置编写的. 以下代码片段提供了使用

JDBC statement的常用方法

Statement接口: 用于执行静态SQL语句并返回它所生成结果的对象. 三种Statement类: Statement: 由createStatement创建,用于发送简单的SQL语句(最好是不带参数的) PreparedStatement: 继承Statement接口,由preparedStatement创建,用于发送含有一个或多个输入参数的sql语句.PreparedStatement对象比Statement对象的效率更高,并且可以防止SQL注入. CallableStatement: