import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
/**
* DESC-根据hibernate.cfg.xml配置文件和相应实体类及其.hbm.xml文件生成对应的数据库表
* 使用步骤:
* 1.建立hibernate.cfg.xml配置文件且在数据库url后面指定数据库名称jdbc:mysql://localhost/DB_NAME(该配置文件放在src根目录)
* 2.建立好相应的POJO类和对应的.hbm.xml文件(需要hibernate.cfg.xml中配置)
* 3.创建数据库:create database DB_NAME;
* 4.打开数据库:use DB_NAME;
* 5.手动执行此类
* @author Administrator
*
*/
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);
}
}
分享到:
相关推荐
hibernate.cfg.xml hibernate框架的配置文件
hibernate.cfg.xml文件详细解释收集的一个比较好的hibernate.cfg.xml文件解释
由于spring对hibernate配置文件hibernate.cfg.xml的集成相当好,可以在项目中放弃hibernate.cfg.xml文件,介绍mappingLocations、mappingDirectoryLocations与mappingJarLocations的用法和区别
这是Hibernate的配置文件,hibernate.cfg.xml的具体写法,共友友们参考~~谢谢~
Hibernate配置文件hibernate.cfg.xml中配置信息详解!
hibernate配置文件hibernate.cfg.xml的详细解释
ORM思想,hibernate介绍,hibernate.cfg.xml配置,hbm.xml映射文件详解,主键生成策略使用,PO对象状态及状态的转换分析、一级缓存,Hibernate数据检索技术,Hibernate高级映射技术,Hibernate多表联合查询, ...
Hibernate.cfg.xml配置总结
ORM思想,hibernate介绍,hibernate.cfg.xml配置,hbm.xml映射文件详解,主键生成策略使用,PO对象状态及状态的转换分析、一级缓存,Hibernate数据检索技术,Hibernate高级映射技术,Hibernate多表联合查询, ...
hibernate.cfg.xml中各节点的所有属性值,取自hibernate官网,纯天然无污染。原装!
(hibernate调用C3p0)hibernate.cfg.xml
activiti.cfg.xml和application.properties文件的整合配置,不能两个都存在,方便,适应
NULL 博文链接:https://15090079858-163-com.iteye.com/blog/1185564
NULL 博文链接:https://javawjy.iteye.com/blog/804577