⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exportdatebase.java

📁 在线考试功能
💻 JAVA
字号:
package com.onlinestudy.domain;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

import java.io.File;

public class ExportDateBase {

	static Session session;

	public static void main(String[] args) {
	Configuration config = null;
	Transaction tx = null;

	try {
	config = new Configuration().configure(new File("src/hibernate.cfg.xml"));
	System.out.println("Creating tables...");
	SchemaExport schemaExport = new SchemaExport(config);
	schemaExport.create(true, true);
	System.out.println("Table created.");
	SessionFactory sessionFactory = config.buildSessionFactory();
	session = sessionFactory.openSession();
	tx = session.beginTransaction();
	tx.commit();

	} catch (HibernateException e) {
	e.printStackTrace();
	try {
	tx.rollback();
	} catch (HibernateException e1) {
	e1.printStackTrace();
	System.out.println("Table created failure");
	}
	} finally {

	}
	}


}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -