Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- Configuration configuration = new Configuration();
- configuration.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
- configuration.setProperty("hibernate.connection.url", "jdbc:mysql://127.0.0.1:3306/foxtrot");
- configuration.setProperty("hibernate.connection.username", "root");
- configuration.setProperty("hibernate.connection.password", "");
- configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
- configuration.setProperty("hibernate.current_session_context_class", "thread");
- configuration.setProperty("hibernate.id.new_generator_mappings", "false");
- configuration.setProperty("hibernate.show_sql", "true");
- configuration.addAnnotatedClass(AccountEntity.class);
- StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder()
- .applySettings(configuration.getProperties());
- return configuration.buildSessionFactory(builder.build());
- } catch (Throwable ex) {
- // Make sure you log the exception, as it might be swallowed
- System.err.println("Initial SessionFactory creation failed." + ex);
- System.out.println(ex.getStackTrace());
- System.out.println(ex.getMessage());
- throw new ExceptionInInitializerError(ex);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement