学习hibernate,使用mysql 5.2,配置什么的都跟网上、视频里讲的一样,就是出现sql语法错误,从控制台看到有这么一句: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。很小众的错误,然后上网搜索,发现type=InnoDB 在mysql 5.0之后就改成engine=InnoDB了,所以会出现sql语法错误。
解决方法:之前在hibernate.cfg.xml中的配置
<!-- hibernate所使用的数据库方言 -->
<property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>,改成
<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property> 就可以了,就加了一个数字5就可以成功运行了。
浙公网安备 33010602011771号