[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1256
  • Last Modified:

2 phase commit by example

Can anyone explain me 2phase commit by small example?
I've two database server base1 and base2.How can i implement 2 phase commit?Pls expalin me with a small live example used in industry..I'm using sql 2000.
0
vivekkj
Asked:
vivekkj
1 Solution
 
ZhongYuCommented:
What you want to do?

To phase commit is implemented in MS DTC (Distributed Transaction Coordinator). As a programmer and administrator, you do not have to do it yourself. If you use middle tier transaction logic, the only thing you have to do is to implement transaction in your component.

 

0
 
mgrajkumarCommented:
Just do
Begin distributed Tran
 
<Sql Statements>

Commit tran
or
Rollback
         
0
 
mgrajkumarCommented:
Just do
Begin distributed Tran
 
<Sql Statements>

Commit tran
or
Rollback
         
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
nigelrivettCommented:
Why do you want a two phase commit?

Basically this is only used where the transaction controller doesn't have close control over all entities involved in the transaction.

The basic idea is that the first phase is 'are we all ready to commit?', second phase 'go ahead and commit?'
Before responding to the first phase the entity is expected to prepare the system so that nothing will hold up the commit.
0
 
sefaCommented:
suppose you have two SQL Servers server_A and server_B
suppose you have two databases server_A.db_1 and server_B.db_2
suppose you have two table server_A.db_1..table_1 and server_B.db_2..table_2

if you want to insert a row into server_A.db_1..table_1 and update a row from server_B.db_2..table_2
in the same transaction you must use distrubted transaction. to do so,
you should place your insert and update sql statements into

BEGIN DISTRIBUTED TRANSACTION
insert into server_A.db_1..table_1 values('hello')
update server_B.db_2..table_2 set my_col='hello'
.
.
.
-- COMMIT DISTRIBUTED TRANSACTION
-- or if any error occured then
-- ROLLBACK DISTRIBUTED TRANSACTION

In this example both insert and update are succesful or not.

to support this feature MS DTC service must be running.
0
 
MoondancerCommented:
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if still open in seven days.  Please post closing recommendations before that time.

Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> You cannot delete a question with comments, special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process for further information, if needed.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.  Anytime you have questions which are LOCKED with a Proposed Answer but does not serve your needs, please reject it and add comments as to why.  In addition, when you do grade the question, if the grade is less than an A, please add a comment as to why.  This helps all involved, as well as future persons who may access this item in the future to seek help.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20109559.html
http://www.experts-exchange.com/questions/Q.20118141.html
http://www.experts-exchange.com/questions/Q.20124163.html
http://www.experts-exchange.com/questions/Q.20125452.html
http://www.experts-exchange.com/questions/Q.20129840.html
http://www.experts-exchange.com/questions/Q.20135140.html
http://www.experts-exchange.com/questions/Q.20135933.html
http://www.experts-exchange.com/questions/Q.20191895.html
http://www.experts-exchange.com/questions/Q.20218509.html


To view your locked questions, please click the following link(s) and evaluate the proposed answer.
http://www.experts-exchange.com/questions/Q.20228009.html
http://www.experts-exchange.com/questions/Q.20225905.html
http://www.experts-exchange.com/questions/Q.20278235.html

PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643

Moderators will finalize this question if still open in 7 days, by either moving this to the PAQ (Previously Asked Questions) at zero points, deleting it or awarding expert(s) when recommendations are made, or an independent determination can be made.  Expert input is always appreciated to determine the fair outcome.
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange

P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.
0
 
NetminderCommented:
Force-accepted by
Netminder
CS Moderator
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now