Advertisement
Guest User

Untitled

a guest
May 1st, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. try {
  2. Configuration configuration = new Configuration();
  3.  
  4. configuration.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
  5. configuration.setProperty("hibernate.connection.url", "jdbc:mysql://127.0.0.1:3306/foxtrot");
  6. configuration.setProperty("hibernate.connection.username", "root");
  7. configuration.setProperty("hibernate.connection.password", "");
  8. configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
  9. configuration.setProperty("hibernate.current_session_context_class", "thread");
  10. configuration.setProperty("hibernate.id.new_generator_mappings", "false");
  11. configuration.setProperty("hibernate.show_sql", "true");
  12.  
  13. configuration.addAnnotatedClass(AccountEntity.class);
  14.  
  15. StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder()
  16. .applySettings(configuration.getProperties());
  17. return configuration.buildSessionFactory(builder.build());
  18. } catch (Throwable ex) {
  19. // Make sure you log the exception, as it might be swallowed
  20. System.err.println("Initial SessionFactory creation failed." + ex);
  21. System.out.println(ex.getStackTrace());
  22. System.out.println(ex.getMessage());
  23. throw new ExceptionInInitializerError(ex);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement