连接数据库工具类
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
/**
* Hibernate Utility class with a convenient method to get Session Factory
* object.
*
*/
public class NewHibernateUtil {
private static SessionFactory msSessionFactory;
private static SessionFactory pgSessionFactory;
private static SessionFactory oracleSessionFactory;
private static SessionFactory mysqlSessionFactory;
@SuppressWarnings("deprecation")
public static SessionFactory getSessionFactory(String type) {
if (SqlType.MS.toString().equals(type)) {
if (msSessionFactory==null) {
msSessionFactory = new AnnotationConfiguration().configure("hibernate.ms.cfg.xml").buildSessionFactory();