I have a.properties
file with configurations. How can I point to it in the code?
It is written everywhere that it is only possible to transmit .XML
file. Why can't I use properties
?
hibernate.properties
hibernate.connection.driver_class = com.mysql.jdbc.Driver
hibernate.dialect = org.hibernate.dialect.MySQLDialect
hibernate.connection.url = jdbc:mysql://localhost:3306/db_example?serverTimezone=Europe/Moscow
hibernate.connection.username = root
hibernate.connection.password = root
hibernate.show_sql = true
hibernate.hbm2ddl.auto = create
Hibernate 5
public class HiberUtil {
private static SessionFactory sessionFactory;
static {
final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
.configure()
.build();
try {
sessionFactory = new MetadataSources(registry)
.buildMetadata()
.buildSessionFactory();
}catch (Exception e){
StandardServiceRegistryBuilder.destroy(registry);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}