0 Replies Latest reply: Aug 11, 2008 4:58 AM by 843844 RSS

    How to use multiple datasource in spring and hibernate

    843844
      HI all,
      I want to use multiple data source for my web application.Please suggest me the mapping of xml files viz.
      applicationContext-resource.xml,applicationContext-hibernate.xml and applicationContext-service.xml
      SHoud i create separate session factory and transaction manager for both the datasource?

      Here is my applicationContext-resource.xml:
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
          "http://www.springframework.org/dtd/spring-beans.dtd">
      <beans>
      <bean id="dataSource"  
                class="org.apache.commons.dbcp.BasicDataSource">
                <property name="url" value="jdbc:oracle:thin:@192.168.x.x:1521:orcl"/>
                <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
                <property name="username" value="dw_lt_staging"/>
                <property name="password" value="dw_lt_staging"/>
      </bean>       
       <bean id="dataSourceAnalytics"  
                class="org.apache.commons.dbcp.BasicDataSource">
                <property name="url" value="jdbc:oracle:thin:@192.168.y.y:1521:orcl"/>
                <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
                <property name="username" value="dw_analytics"/>
                <property name="password" value="dw_analytics"/>
      </bean>            
      </beans>
      Thanks in advance.