Created
June 6, 2018 18:34
-
-
Save shankybnl/43d2801783b6123f7fb0237d053d993e to your computer and use it in GitHub Desktop.
HibernateUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HibernateUtil { | |
private static final SessionFactory sessionFactory; | |
static { | |
try { | |
Configuration cfg = new Configuration(); | |
cfg.setProperty("hibernate.connection.url", CommonUtil.loadTestData.getString("connection.url")); | |
cfg.setProperty("hibernate.connection.username", CommonUtil.loadTestData.getString("connection.username")); | |
cfg.setProperty("hibernate.connection.password", CommonUtil.loadTestData.getString("connection.password")); | |
cfg.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect"); | |
cfg.configure(); | |
sessionFactory = cfg.buildSessionFactory(); | |
} catch (Throwable ex) { | |
System.err.println("SessionFactory creation failed" + ex); | |
throw new ExceptionInInitializerError(ex); | |
} | |
} | |
public static SessionFactory getSessionFactory() { | |
return sessionFactory; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment