import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
public class ExportDB {
public static void main(String[] args) {
//读取hibernate.cfg.xml文件
Configuration cfg = new Configuration().configure();
SchemaExport export = new SchemaExport(cfg);
export.create(true, true);
}
}
本文介绍了一个简单的Java程序,该程序使用Hibernate框架从现有的配置中自动创建数据库表结构。通过加载hibernate.cfg.xml配置文件并利用SchemaExport工具类,可以实现数据库模式的自动化创建。

被折叠的 条评论
为什么被折叠?



