Hibernate(二):MySQL server version for the right syntax to use near 'type=InnoDB' at line x
目前使用的hibernate5.2.9版本,配置的mysql方言为:
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
使用的表更新策略为:
<property name="hibernate.hbm2ddl.auto">create</property>
可是每次执行都出现了以下错误:
INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
Hibernate: drop table if exists NEWS
四月 15, 2017 1:38:33 下午 org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection
INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@180e6ac4] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
Hibernate: create table NEWS (
ID integer not null auto_increment,
AUTHOR varchar(255),
CONTENT varchar(255),
CREATEDATE datetime,
primary key (ID)
) type=InnoDB
四月 15, 2017 1:38:33 下午 org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection
INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@305f031] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
四月 15, 2017 1:38:33 下午 org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleException
WARN: GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement
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:440)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:424)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:315)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:166)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:155)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:445)
at com.dx.hibernate5.test.HelloWord.main(HelloWord.java:40)
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 7
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:403)
at com.mysql.jdbc.Util.getInstance(Util.java:378)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1031)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3361)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3295)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1852)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1975)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2470)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2399)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:718)
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)
... 11 more
根据提示很显然得知:这是MySQL的版本问题导致的问题。
实际上,在MySQL5.0以前,type=InnoDB是有效的SQL语句,但是自己用的是MySQL5.7版本,type=InnoDB不再有效了。

解决办法就是修改hibernate.cfg.xml中的dialect属性,将
<property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
修改为
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
再次运行,发现可以自动建表了。
Hibernate(二):MySQL server version for the right syntax to use near 'type=InnoDB' at line x的更多相关文章
- ERROR: 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 7
问题: 使用hibernate4.1.1,数据库使用mysql5.1.30,使用hibernate自动生成数据库表时,hibernate方言使用org.hibernate.dialect.MySQLI ...
- check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB' at line 7
第一种是:解决MySQL的版本问题(我用的是mysql 5.5版本),mysql 5.0版本以后的数据库方言是:org.hibernate.dialect.MySQ5LInnoDBDialect.第二 ...
- MySQL server version for the right syntax to use near 'TYPE=MyISAM'
最近将一个版本为4.0.18-Max的MySQL数据库迁移到5.6.20-enterprise-commercial-advanced上.好吧,这是我迄今为止,见到过的最古老版本的MySQL数据库,这 ...
- 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 'like '%逸%'' at line 1
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-/ ...
- MySQL server version for the right syntax to use near 'type=InnoDB' at line 1
转载请注明出处:http://blog.csdn.net/bettarwang/article/details/40180271 在执行一个Hibernate的演示样例时,配置了<propert ...
- 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 ...
下面是我update数据库时打印出来的异常: ### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSynt ...
- 解决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 'order (order_name, customer)
在学习hibernate一对多映射关系时,根据视频学习的时候,例子是顾客和订单的问题,一个顾客有多个订单.按照视频中的敲代码出现了You have an error in your SQL synta ...
- [Err] 1064 - 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 ''<h1 style="text-align: center;">php
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL s ...
- C# Mysql 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 ????
有几年没用过MySql数据了,今天在使用C#访问MySql数据库时出现了一个小插曲. 错误提示: You have an error in your SQL syntax; check the man ...
随机推荐
- Mycat 常用管理命令说明
Mycat 提供了类似数据库的管理监控方式,可以通过 MySQL 命令行登陆管理端口 9066 执行相应的 SQL 语句进行管理,可以可以通过 JDBC 的方式进行远程连接管理,使用 MySQL 命令 ...
- 笔记:Maven 创建 Nexus 私服
首先从 http://nexus.sonatype.org/downloads/ 下载最新版本的Nexus,下载 bundle 包,不需要Web容器. windows 系统安装 目录结构说明 目录 说 ...
- python统计词频
arr = [1,2,3,4,5,6,4,5,2,3,6,8,9,6,5,3,6,2,4]dic={}for item in arr: if item in dic.keys(): dic[item] ...
- es6学习笔记--promise对象
Promise对象是为了简化异步编程.解决回调地狱情况 Promise,简单说就是一个容器,里面保存着某个未来才会结束的事件(通常是一个异步操作)的结果.从语法上说,Promise 是一个对象,从它可 ...
- 【Docker】 Swarm简单介绍
[Swarm] Swarm是Docker官方提供的一款集群管理工具,其主要作用是把若干台Docker主机抽象为一个整体,并且通过一个入口统一管理这些Docker主机上的各种Docker资源.Swarm ...
- mqtt异步publish方法
Python基于mqtt异步编程主要用到asyncio及第三方库hbmqtt,这里主要介绍mqtt的异步发布及遇到的一些问题. hbmqtt安装很简单,pip hbmqtt install. mqtt ...
- 福州大学W班-助教总结
开学初对自己的期望 在即将到来的学期前,我希望我可以做到以下几点: 1.多参与同学的课程设计,并提出自己的见解 2.不断提高个人的专业技能,活到老学到老 3.能够及时对同学的博客进行评论,并给出有用的 ...
- 201621123062《java程序设计》第五周作业总结
1. 本周学习总结 1.1 写出你认为本周学习中比较重要的知识点关键词 关键词:interface.Comparable.comparator 1.2 尝试使用思维导图将这些关键词组织起来.注:思维导 ...
- 每日冲刺报告--Day2
敏捷冲刺每日报告--Day2 情况简介 今天我们三个人在一起开了会,分析了我们面临的情况以及下一阶段的计划.一个重大的改进是,我们准备把之前用txt文件格式存储订阅列表改成了文件json格式. 任务进 ...
- Alpha冲刺Day6
Alpha冲刺Day6 一:站立式会议 今日安排: 由张梨贤继续完成前一天委托第三方剩余的内容,并完成委托情况查看这一子模块 由黄腾飞继续完成前一天企业自查风险管理剩余的内容,并完成风险上报这一子模块 ...