首页 > 代码库 > MySQL server version for the right syntax to use near 'type=InnoDB' at line 1
MySQL server version for the right syntax to use near 'type=InnoDB' at line 1
转载请注明出处:http://blog.csdn.net/bettarwang/article/details/40180271
在执行一个Hibernate的演示样例时,配置了<property name="hibernate.hbm2ddl.auto">update</property>属性,可是自己主动建表却一直不成功,出错信息为:
ERROR: HHH000388: Unsuccessful: create table info_table (id integer not null auto_increment, title varchar(255), content varchar(255), primary key (id)) type=InnoDB
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 1
非常显然,这是MySQL的版本号问题导致的,实际上,在MySQL5.0曾经,type=InnoDB是有效的SQL语句,可是自己用的是MySQL5.5版本号,type=InnoDB不再有效了。
解决的方法就是改动hibernate.cfg.xml中的dialect属性,将
<property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>改动为
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
再次执行,发现能够自己主动建表了。
MySQL server version for the right syntax to use near 'type=InnoDB' at line 1