首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

项目联接两个数据库

2012-06-26 
项目连接两个数据库写两个hibernate配置文件,一个是“hibernate.cfg_b.xml”,另一个是“hibernate.cfg.xml”。s

项目连接两个数据库

写两个hibernate配置文件,一个是“hibernate.cfg_b.xml”,另一个是“hibernate.cfg.xml”。
spring的配置文件(applicationContext.xml)中是以下配置:

<bean id="sessionFactoryb" value="classpath:hibernate.cfg_b.xml"></property></bean> <bean id="sessionFactory" value="classpath:hibernate.cfg.xml"></property></bean>
?



现在想分别获得两个数据库连接的Session,

SessionFactory sessionFactoryb = (SessionFactory)application.getBean("sessionFactoryb");SessionFactory sessionFactory  = (SessionFactory)application.getBean("sessionFactory");//application->Spring容器Session sessionB = sessionFactoryb.getCurrentSession();Session session = sessionFactory.getCurrentSession();
?

热点排行