我在学习Hibernate的过程中,遇到了这样一个错误:JUnit测试通过,但是数据库中却没有创建一个表,控制台的错误信息如下:

HHH000388: Unsuccessful: create table t_user (user_id bigint not null auto_increment, card_number varchar(30), card_type varchar(20), company_name varchar(200), email varchar(100), gender varchar(100) not null, identity varchar(20), job_name varchar(60), mobile varchar(30) not null, password varchar(100) not null, real_name varchar(100) not null, primary key (user_id)) type=InnoDB

2014-11-10 10:27:10,749 ERROR (org.hibernate.tool.hbm2ddl.SchemaUpdate:237) - 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 14

2014-11-10 10:27:10,756 ERROR (org.hibernate.tool.hbm2ddl.SchemaUpdate:236) - HHH000388: Unsuccessful: create table t_word (word_id bigint not null auto_increment, content longtext not null, create_date datetime, modify_date datetime, title varchar(100) not null, author_id bigint, primary key (word_id)) type=InnoDB

2014-11-10 10:27:10,763 ERROR (org.hibernate.tool.hbm2ddl.SchemaUpdate:237) - 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 9

2014-11-10 10:27:10,767 ERROR (org.hibernate.tool.hbm2ddl.SchemaUpdate:236) - HHH000388: Unsuccessful: create table t_wordreply (reply_id bigint not null auto_increment, content longtext not null, reply_date datetime, replier_id bigint, word_id bigint, primary key (reply_id)) type=InnoDB

可以看到自后都是type=InnoDB,网上搜索了之后,原来是type=InnoDB 是5.0之前使用的,我的数据库是5.5的

这个时候需要把hibernate中mysql的方言改一下,

原来的:hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect

改成:hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect

hibernate4连接mysql自动创建表之错误的更多相关文章

  1. 吴裕雄--天生自然 PHP开发学习:连接 MySQL、创建表

    <?php $servername = "localhost"; $username = "root"; $password = "admin& ...

  2. Hibernate连接mysql数据库并自动创建表

    天才第一步,雀氏纸尿裤,Hibernate第一步,连接数据库. Hibernate是一个开放源代码的对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,它将POJO与数据库表建立映射关系,是一个 ...

  3. mysql 按照月份自动创建表,以年和月为表明,动态生成。

    需求:mysql5.5 数据库,想要根据月份自动创建表,每个月创建一张表,需要数据库自动创建,并根据当前年和月动态生成表名称. 解决办法:1 连接数据库工具为Navicat  2  首先创建存储过程, ...

  4. (Win10)Java,Maven,Tomcat8.0,Mysql8.0.15安装与环境配置,以及IDEA2019.3使用JDBC连接MySQL、创建JavaEE项目

    之前用windows+linux的双系统,最近不怎么舒服就把双系统给卸了,没想到除了问题,导致有linux残余,于是就一狠心重装了电脑,又把Java及其相关的一些东西重新装了回来,还好当初存了网盘链接 ...

  5. Hibernate自动创建表

    只要在hibernate.cfg.xml添加这句话,就可以自动生成数据表 <property name="hibernate.hbm2ddl.auto">update& ...

  6. Hibernate 自动创建表bug问题解决

    我在hibernate.cfg.xml配置文件中添加了自动创建表的的属性:(这样当数据库中没有此表是,hibernate就会自动帮我们创建一张表) <property name="hb ...

  7. MYSQL定时创建表分区

    MYSQL定时创建表分区 一.存储过程-表分区-----------------------------------------------------------------需求: 每月创建一个分区 ...

  8. Hibernate根据实体类自动创建表

    Hibernate支持自动建表,在开发阶段很方便,可以保证hbm与数据库表结构的自动同步. 如何使用呢?很简单,只要在hibernate.cfg.xml里加上如下代码 Xml代码<propert ...

  9. hibernate自动创建表报表不存在

    在hibernate.cfg.xml配置了<property name="hibernate.hbm2ddl.auto">update</property> ...

随机推荐

  1. hibernate查询返回一个list ,Date类型追加数据

    public Pagination getLookPage(BeanPatrolScheduling beanPatrolScheduling, int pageNo, int pageSize) { ...

  2. 【windows】跑大型程序时不要休眠和睡眠

    win10系统. 为了节能,长时间没有操作操作系统会自动进入休眠模式. 先前设定了"控制面板\硬件和声音\电源选项\编辑计划设置",都设定为"从不",结果不起作 ...

  3. mysql导入sql文件,乱码,一个例子

    服务器centos,其他数据库都是utf8都正常能用 网页正常显示 这次导入一个utf8格式数据库文件 结果网页上乱码 在导出的sql文件中,注释部分有些语句也是被mysql考虑的.导出的sql文件, ...

  4. 【bzoj2245】 SDOI2011—工作安排

    http://www.lydsy.com/JudgeOnline/problem.php?id=2245 (题目链接) 题意 n个产品,每个需要造C[i]件:m个员工,每个员工可以制造一些产品:每个员 ...

  5. bzoj3295: [Cqoi2011]动态逆序对(cdq分治)

    #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #i ...

  6. QCustomPlot 使用整理

    QCustomPlot 是一个比较小的 QT 图表插件.使用时,我们在程序中写完相关调用的代码后,只需将 QCunstomPlot.cpp 和 QCustomPlot.h 两个文件加入工程,正常编译即 ...

  7. C/C++ 程序的build过程

    (This article is under constant construction) DISCLAIMER: 本文的主要内容来自https://gcc.gnu.org/onlinedocs/gc ...

  8. django1.8 提示(1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your defau

    原因是升级之后不推荐使用单独的 TEMPLATES_DIR这样的设置了,使用TEMPLATE = []这种就好了 详细见https://openedx.atlassian.net/browse/TNL ...

  9. 用DOS命令配置服务开机自启动

    2016-08-19 15:01 Create 使用命令  sc  config 参考博客:http://blog.csdn.net/it1988888/article/details/7992626 ...

  10. MooseFs-分布式文件系统系列(二)之安装总结

    preface 上篇博客写了如何安装MFS,那么现在就说说经验总结把 安装方式有源码和yum安装,在官网地址:https://moosefs.com/download/centosfedorarhel ...