Announcement Announcement Module
Collapse
No announcement yet.
Multiple data sources in Spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple data sources in Spring

    Hi
    Is there anyway of configuring multiple data sources under the same session factory or the same transaction manager? I am trying to access 2 oracle databases in 2 different machines. Can anyone provide a sample Spring configuration for such a setup ? All the examples I have seen use a single datasource. There is also a mention to use JTA for multiple data sources. Could someone clarify on this on how to configure using JTA.

  • #2
    Look at the JPetStore sample application for an example of Spring with JTA. You define a JNDI datasource like this:

    Code:
    <bean id="dataSource" 
       class="org.springframework.jndi.JndiObjectFactoryBean">
       <property name="jndiName" value="jdbc/jpetstore/">
    </bean>
    And a single JTA transaction manager like this:
    Code:
    <bean id="transactionManager"   
       class="org.springframework.transaction.jta.JtaTransactionManager"/>

    Comment

    Working...
    X