Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Whats the best way to maintain consistency between two databases?

If i have two separate databases, and i am inserting in both databses and calling commit on both connections. if due to some problem lets say some network problem, second commit failed. how do we handle this? as the data is inserted in database1 but not in database2?

user-image
Question added by Ameer Pasha Md , Senior Software Analyst , intergraph
Date Posted: 2014/02/23
Ameer Pasha Md
by Ameer Pasha Md , Senior Software Analyst , intergraph

Hi John, 

thanks for you answer. But my situation is

 

Begintransaction1();

Begintransaction2();

 

Insert1();

Insert2();

 

commit1();

commit2();

 

if an exception occurs at commit2. then how shall we handle it? because the data in database1 got committed and cannot be rollbacked.and no data got inserted in database2, making the databases inconsistent

 

Nitya John
by Nitya John , Senior Systems Developer , American University of the Middle East

If inserting into both the databases are EQUALLY important, why dont you do commit after second insert.

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.