龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > Jsp编程 >

根据Hibernte的cfg文件生成sql文件

时间:2014-06-15 16:05来源:网络整理 作者:网络 点击:
分享到:
今天尝试用Hibernate的配置文件生成数据库脚本,结果居然成功了,代码很简单
代码如下:

public void exportHibernteToSQL(){
Configuration cfg=new Configuration().configure("/hibernate.cfg.xml");
SchemaExport schemaExport = new SchemaExport(cfg);
schemaExport.setOutputFile("d:/mysql_sql.sql");
schemaExport.create(true, false);
}

注意:Hibernate的配置文件是什么数据库方言和驱动,将生成什么数据库脚本。
精彩图集

赞助商链接