我在学习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. C++强制类型转换操作符 dynamic_cast

    dynamic_cast是四个强制类型转换操作符中最特殊的一个,它支持运行时识别指针或引用. >>>>>>>>>>>编译器的RTTI设 ...

  2. angularjs 手动加载

    利用ng-app可以完成自动加载,如果不利用ng-app.那么使用bootstrarp实现手动加载模块 <html> <head> <script src="a ...

  3. WebStorm工具插件下载安装

    在webstorm工具中安装插件 ,找到File->Setting->Plugins  然后搜索你想要的插件安装即可. 例如,我们安装weex插件

  4. persistent.xml hibernate 利用sql script 自定义生成 table 表

    <?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http:// ...

  5. Linux rsync网站目录同步功能的实现

    实现目标: 172.16.1.64服务器上的/var/www/sw_service目录,与172.16.1.60服务器上的/var/www/sw_service目录实现同步, 即1.60主动向1.64 ...

  6. Linux下shell脚本中信号捕获和函数练习脚本之ping一个网段

    该脚本主要的目的是练习在Linux bash脚本中捕获信号,顺便练习一下函数的使用,还有就是终止一个正在运行的程序后,该程序打开的文件的后续处理问题等等!脚本功能:  ping一个网段内的IP,检测哪 ...

  7. MongoDB系列一(索引及C#如何操作MongoDB)

    索引总概况 db.test.ensureIndex({"username":1})//创建索引 db.test.ensureIndex({"username": ...

  8. 【原】flux学习笔记

    最近React(web/native)依旧如火如荼,相信大家都跃跃欲试,入职新公司,现在的团队也开始在React领域有所尝试. 2016年应该是React 逐渐走向成熟的一年.之前在原来公司搞不懂的问 ...

  9. c中三大区的解析

    1.栈,堆和静态存储区是 堆和静态存储区是C语言程序常涉及的三个基本内语言程序常涉及的三个基本内存区2.栈区主要用于函数调用的使用3.堆区主要是用于内存的动态申请和归还4.静态存储区用于保存全局变量和 ...

  10. IIS Express 外部访问

    http://blog.csdn.net/zhangjk1993/article/details/36671105