Changing datasource connection url runtime

前端 未结 3 1537
生来不讨喜
生来不讨喜 2020-12-14 13:30

I am working on a project which uses spring + hibernate + mysql and c3p0 for connection pooling.

Currently the properties for the connection pool are loaded via prop

3条回答
  •  遥遥无期
    2020-12-14 14:29

    If you are asking for multiple databases connections ..it is possible with hibernate by creating multiple hibernate.cfg.file 's which is some what inappropriate

    By following line you can acheive that .

    SessionFactory sf = new Configuration().configure("somename.cfg.xml").buildSessionFactory();
    

    When your primary connection not established you have load another hibernate configuration ...otherwise is wont possible .

提交回复
热议问题