my problem is ;
l am using struts1
l have two datasource and in my project l have to insert some data to two different table.
TableA and TableB have different datasource.
And l want to insert some data to the TableA and according to the insertation result of TableA (l meant succes or failure) l must insert data to the TableB.
question is assume that l achieve successfully insert data to the TableA and commit it.But than in insertation operation of TableB become failure, in this case l am deleting rows in TablaA .
are there any way to solve this problem in one transaction
However, both (or at least one for 1.5 PC) data sources must be able to participate in 2PC. (You need to google if you don't know 2 or 1.5 Phase Commit). If you are using commercial databases such as Oracle, Sybase, MSSQL, they do support XA transactions.
are you using Spring AOP transactions or Hibernate or EJB or Simple JDBC?
do you need to commit the data in the Table A and Table B irrespective failure?
Joined: Apr 23, 2013
l am using struts1 + jpa + DB2
as id l am using RSA(rational Software architech for websphere)
l need to commit when the all operation success, l meant insertation operation of TablaA and TableB when become success than l want to commit
As you know when we use one datasource, if we want to insert data two different table, during the insertation operation of any table if any exception is occured than all insertation is rolled back
in "catch" part of code block.
Look below code l mean something like that
But waht we can do if we have more than one datasource l can not handle and control all thing in one transaction.
Because there is a table in any database and there is another table in different database.
How they(both tables) can communicate eachother when any exception occurs.
l want to roll back all insertation when any exception occurs
suppose that l achive to insert data to TableA and commited.
All rows are inserted in TableA but than when l insert data to TableB any exception occurs and unable to insert rows to TableB
in this case l want to roll back rows which were inserted before TableA.
Normally in one data source and in one transaction to manage this easy.