Announcement Announcement Module
Collapse
No announcement yet.
Spring JDBC and Transaction Mgmt Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring JDBC and Transaction Mgmt

    Hi:

    I am inserting rows into two tables, one in Oracle database and the other in MS SQL Server. The program works fine. Now I want to introuduce transaction support. If anything goes wrong, none of the tables should have the new rows. How can I configure this? Can I have 2 data sources in DataSourceTransactionManager?

    Thanks in Advance

    Code:
    	<!--  Define MICenter Database Connection Properties -->
    	<bean id="dataSource1"
    		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    		<property name="driverClassName">
    			<value>oracle.jdbc.driver.OracleDriver</value>
    		</property>
    		<property name="url">
    			<value>jdbc:oracle:thin:@localhost:1521:sid</value>
    		</property>
    	</bean>
    
    	<!--  Define MS Sql Server Jounaling Database connection properties -->
    	<bean id="dataSource2"
    		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    		<property name="driverClassName">
    			<value>net.sourceforge.jtds.jdbc.Driver</value>
    		</property>
    		<property name="url">
    			<value>
    				jdbc:jtds:sqlserver://server:1433/database
    			</value>
    		</property>
    	</bean>
    
    	<!--  Deinfe transaction -->
    	<bean id="transactionManager"
    		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    		<property name="dataSource" ref="dataSource1" />
    ??????
    	</bean>

  • #2
    Have you looked into using JTA?
    Last edited by karldmoore; Aug 27th, 2007, 03:57 PM.

    Comment


    • #3
      Originally posted by bostonjava View Post
      Can I have 2 data sources in DataSourceTransactionManager?
      Just to make it clear: You can't but have to use distributed transactions and so JTA. Spring provides support via the JtaTransactionManager.

      Joerg

      Comment

      Working...
      X