---
title: "利用Hibernate导出生成数据库表"
author: "hlbng"
date: "2009-05-26T11:20:36Z"
tags: []
slug: "hibernate"
draft: false
lastmod: "2009-06-04T08:43:39Z"
id: 396092
url: "https://hlbng.iteye.com/blog/396092"
---

```
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

import junit.framework.TestCase;

public class CreateDB extends TestCase{

	public void testCreateDB(){
		Configuration cfg=new Configuration().configure("hibernate.cfg.xml");
		SchemaExport export=new SchemaExport(cfg);
		export.create(true, true);
	}
}
```