简体   繁体   English

如何在Hibernate中使用多个数据库?

[英]How to use multiple databases in Hibernate?

I have a requirement that I need to create the more than one database to my application,when user login based on there ID need to pick the username and password from the corresponding database and Login.(With out using more than one sessoinfactory).only by creating hibernate cfg. 我有一个要求,我需要为我的应用程序创建一个以上的数据库,当基于该ID的用户登录需要从相应的数据库中选择用户名和密码并登录时(不使用多个sessoinfactory)。通过创建休眠cfg。

SessionFactory sessionFactory1 = new  Configuration().configure("oracleconfig.cfg.xml").buildSessionFactory();
    SessionFactory sessionFactory2 = new Configuration().configure("derbyconfig.cfg.xml").buildSessionFactory();

here its herd coded the cfg file how i can give dynamically. 在这里,它的畜群编码了cfg文件,我该如何动态地给它。

要生成和更改休眠连接,您可能会喜欢以下链接: Hibernate Documentation-Chapter 3:Configuration

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM