How to use hibernate.properties file instead of hibernate.cfg.xml

后端 未结 4 1592
清酒与你
清酒与你 2021-02-13 00:36

I am trying to connect to DB in a servlet using Hibernate.I have read that we can use either hibernate.cfg.xml or hibernate.properties file for configuration of session.For me i

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-13 01:15

    This code will call hibernate.cfg.xml by default:

    Configuration configuration = new Configuration().configure();
    

    And this code will call hibernate.properties by default:

    Configuration configuration = new Configuration();
    

    Hope it helps.

提交回复
热议问题