欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2024-02-18 21:09:34
复制代码 代码如下:public void exporthiberntetosql(){ configuration cfg=new configuration().con...
复制代码 代码如下:

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的配置文件是什么数据库方言和驱动,将生成什么数据库脚本。