Transaction Processing for Distributed Heterogeneous Databases

Source: Internet
Author: User
Tags oracleconnection

On the blog, we can see that "system design should focus on concurrency"ArticleAs mentioned in transaction processing for distributed heterogeneous databases, it seems that there is no way for everyone.

As we all know, after a transaction is committed, it is no longer valid to perform the roolback operation for this transaction.

Then we can catch the exception before the transaction is cmmit.

For example, there are currently two connections: one is the connection of the local SQL database, called localconnection, and the other is the connection of Oracle on the server called oracleconnection.

Currently, there are two operations on localconnection and two operations on oracleconnection. We first open two transactions ()

Try

{

.

Localcommand. executenonquery () // Localcommand is a command of localconnection.

Localcommand2.executenonquery () // Localcommand2 is a command of localconnection.

..

Oraclecommand. executenonquery () // Oraclecommand is a command of oracleconnection.

Oraclecommand2.executenonquery () // Oraclecommand2 is a command of oracleconnection.



Localconnection. Commit ();

Oracleconnection. Commit (); // Two transaction commits



} Catch

{

Localconnection. roolback ();

Oracleconnection. roolback ();//Two transaction rollback



} Final

{

Localconnection. Close ();

Oracleconnection. Close ();//Two connections close ()

}


In this case, if there is an exception, neither transaction will be committed.

I don't know if this method is correct. You are welcome to discuss it.

I implemented this method in SPL and the test passed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.