Error executing DDL via JDBC Statement测试hibernate配置自动建表时出现的异常

测试hibernate配置
public class Student {
	private int id;
	private String name;
	private int age;
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	
hibernate方言配置为
org.hibernate.dialect.MySQLDialect
异常
 Error executing DDL via JDBC Statement

控制台输出建表语句为:

Hibernate: 
    
    create table Student (
       id integer not null,
        name varchar(255),
        age integer,
        primary key (id)
    ) type=MyISAM
判断 hibernate.cfg.xml中的sql方言配置出现问题,

由于使用的是MySQL5之后的版本,现将hibernate.cfg.xml配置改为

org.hibernate.dialect.MySQL5InnoDBDialect
之后,控制台输出sql建表语句为
Hibernate: 
    
    create table Student (
       id integer not null,
        name varchar(255),
        age integer,
        primary key (id)
    ) engine=InnoDB
并且正常运行,自动建表成功

你可能感兴趣的:(java)