Announcement Announcement Module
Collapse
No announcement yet.
Multiple Datasources/Database in one spring transaction Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple Datasources/Database in one spring transaction

    Hello Experts,

    I'm a newbie to the spring world and would need youe expert advise on one of my situation today. I'm working on a core java batch program and I've an operation which executes a db insert/update to an oracle database as well as a sybase database. I want both these calls to be in one single transaction.

    Intially I had only one DS and I managed as below :

    <tx:annotation-driven transaction-manager="txManager" />
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
    <property name="dataSource" ref="oracleDataSource" />
    </bean>

    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED, readOnly = false)
    public boolean executeServices(){
    .........
    .....
    }
    For Oracle I'm using OracleConnectionPoolDataSource & for sybase I'm using JtdsDataSource. Any help will be much appreciated.
    Last edited by itsmeanand; Jan 29th, 2013, 06:52 PM.

  • #2
    You would need a JTATransactionManager to support two phase XA commits. Other transaction managers can only manage one transactional resource, like in your case just one db in a single transaction.

    Mark

    Comment

    Working...
    X