前提是开发框架包含hibernate支持
package com.exam.util;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
public class CreateDB {
public static void main(String[] args) {
// TODO Auto-generated method stub
//读取.xml配置文件
Configuration cfg = new Configuration().configure();
//创建SchemaExport对象
SchemaExport export = new SchemaExport(cfg);
//创建数据库表
export.create(true,true);
}
}