Miki<br /> <br />SCJP 1.4, SCBCD 1.3
Miki<br /> <br />SCJP 1.4, SCBCD 1.3
Originally posted by Miki Muzsi:
This might be a dumb questiuon but I am a bit confused at this our regarding transactions in general...
Considering the code:
...
Context initContext = new InitialContext();
DataSource ds1 = (DataSource)initContext.lookup("java:comp/env/db1");
Connection con1 = ds1.getConnection();
DataSource ds2 = (DataSource)initContext.lookup("java:comp/env/db2");
Connection con2 = ds2.getConnection();
UserTransaction tx = ejbContext.getUserTransaction();
tx.begin();
//use the connection to update database 1.
//use the connection to update database 2.
tx.commit();
con1.close();
con2.close();
...
I was wondering, when the user starts a transaction ( tx.begin() , both databases are locked? So the transaction is associated with two databases? What if one is oracle the other is sqlserver? Basically both databses must successfully commit, which I think is just no way to control that...
Miki
In non-2PC situation, i think each operation would involve in normal transaction. rollback of one would cause rollback of other too.
Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
In non-2PC situation, i think each operation would involve in normal transaction. rollback of one would cause rollback of other too. If I am wrong, correct me.
rollback of one would cause rollback of other too
Miki<br /> <br />SCJP 1.4, SCBCD 1.3
After this in one transaction you can use these two datasource to get the connections that will participate in 2-phase commit. Although I think that this won't work with JTA.
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
You can start a JTA user transaction after a transacted session has been started; however, the JTA transaction will be ignored by the session and vice versa.
WebLogic Server supports the two-phase commit protocol (2PC), enabling an application to coordinate a single JTA transaction across two or more resource managers. It guarantees data integrity by ensuring that transactional updates are committed in all of the participating resource managers, or are fully rolled back out of all the resource managers, reverting to the state prior to the start of the transaction.
Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
If you need JMS and EJB operations to be done in a transaction, you need a JTA transaction in a non-transacted JMS session.
Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
Are you okay? You look a little big. Maybe this tiny ad will help:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|