hibernate--MYSQL建表时type=InnoDB和Engine=InnoDB注意点

hibernate初学在配置好一切之后,运行然后报错,接下来问度娘,最后解决。。。
首先看报错

[org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@6cea706c] 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,
        TITLE varchar(255),
        AUTHOR varchar(255),
        DATE date,
        primary key (ID)
    ) type=InnoDB
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
WARN: GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement
Hibernate: 
    insert 
    into
        NEWS
        (TITLE, AUTHOR, DATE) 
    values
        (?, ?, ?)
WARN: SQL Error: 1146, SQLState: 42S02
ERROR: Table 'hibtest.news' doesn't exist

里面有建表语句:

Hibernate: 

    create table NEWS (
       ID integer not null auto_increment,
        TITLE varchar(255),
        AUTHOR varchar(255),
        DATE date,
        primary key (ID)
    ) type=InnoDB

报错也说了

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

我们这里出来问题,这是mysql5.1以前的写法,5.1之后变化如下:

engine = InnoDB

现在找出问题所在,我们只要修改hibernate.cfg.xml中的方言配置就可以了,不需要修改其他的
正确的做法如下:
这里写图片描述

org.hibernate.dialect.MySQL5InnoDBDialect
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

走到无路可退

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值