XA Transaction - Solution for Transaction More Than One Database
Have you ever think that it's too difficult for making database transaction in two different places (or databases) ? If so, XA Transaction is one of solutions. XA Transaction will make data for being consistent in both places and will be maintained in accordance with the principle of ACID.
Have you ever think that it's too difficult for making database transaction in two different places (or databases) ? If so, XA Transaction is one of solutions. XA Transaction will make data for being consistent in both places and will be maintained in accordance with the principle of ACID.
In this XA Transaction, the concepts is 2PC or Two-Phase Commit. So, we could use 2 databases for our transaction and each database could make it's own transaction and then at the end of all transactions, we could join all the transaction to commit or rollback the transactions as the one action.
Here is an example application with XA Transaction 2PC in PostgreSQL, namely:
// Start a local transaction
BEGIN;
// Make the data change process ... it could be anything:-P
INSERT INTO dd_users (user_name, pass_word) VALUES ( 'hadi', 'ARIWIBOWO');
// Prepare this transaction to 2PC
Prepare TRANSACTION 'xatest';
// Doing the settlement for local transactions
COMMIT;
// ... Or
ROLLBACK;
// Now we can see the status of existing 2PC transaction with ...
SELECT * FROM pg_prepared_xacts;
// Finish 2PC to commit ...
Prepared COMMIT 'xatest';
// ... Or
Prepared ROLLBACK 'xatest';
For MySQL (version 5.0 and above), 2PC process may be done by:
// Start a transaction 2PC, unlike PostgreSQL
XA START 'xatest';
// Make the data change process ... it could be anything:-P
INSERT INTO dd_users (user_name, pass_word) VALUES ('hadi', md5 ('ARIWIBOWO'));
// Enter idle stage ...
XA END 'xatest';
// Preparing the transaction 2PC
XA Prepare 'xatest';
// Now we can see the status of existing 2PC transaction with ...
Recover XA;
// Finish 2PC to commit ...
XA COMMIT 'xatest';
// ... Or
XA ROLLBACK 'xatest';
Ok, that's all ... for implementation..it's up to you :-)
-
XA Transaction - Solution for Transaction More Than One Database
| By H4d1 | in Programming
Have you ever think that it's too difficult for making database transaction in two different places (or databases) ...
-
An overview of data warehousing
| By BarryM | in General
Data warehousing is the mechanism that makes it possible to transform the data contained in the complex technology ...
-
Database Associations Overview
| By Chrys | in Programming
In this part of the series, we look at Database Associations Overview....
-
How To Recover Lost Data From A Computer
| By MB11 | in Computers
This article provides several guidelines for recovering back lost data from a computer that can have a lot of impor...
-
Understanding Data Management and Data Security
| By Lydia87 | in Computers
Companies today have so much data that flows in and out of the office that they need an effective system in place t...
-
iPhone Resizing a UIImage | By eh9212 | in Programming
How to resize a UIImage in a UIImageView and a UIButton...
-
Threading in dot net 2.0 - separate copy of static variable among different threads using ThreadStatic attribute | By xxris | in Programming
How each thread keeps a separate copy of same static variable using ThreadStatic attribute ....
-
ADAPATIVE ALGORITHM TO FINDOUT DUPLICATE RECORDS | By pinakbhusanmishra | in Programming
Records are list of row that are stored inside database . this is an efficient technique to find out the duplicatin...
-
ALGORITHM TO FIND OUT HIDDENLINKS IN WEBSITES | By pinakbhusanmishra | in Programming
Here we can find out the hidden links in the websites that basically people uses for the browsing ads....
-
PHP and MySQL | By ChaimChaikin | in Programming
PHP is a server side programming language that is used mainly for dynamically creating and mantaining websites. PHP...
-
Slony-I Configuration in Windows XP Operating System | By H4d1 | in Programming
Replication is a common thing for databases that require more performance. One application that can be used in repl...
-
Online Business Review Of InterADMedia - Browsing That Pays You Daily! | By H4d1 | in Home & Online Business
Based on searching results on the website, introduced me to an online business that I never follow, the online busi...
-
Introduction To Simple Routing On Win32 | By H4d1 | in Software
For computer networks involving many segments, the need for routing is not inevitable. Routing largely responsible ...
-
XA Transaction - Solution for Transaction More Than One Database | By H4d1 | in Programming
Have you ever think that it's too difficult for making database transaction in two different places (or databases) ...
-
wget - Good Solution for Downloading the Internet Pages | By H4d1 | in Software
Sometime we need tools for downloading web pages. By using wget, we could do the same thing. Each softwares or tool...








No comments yet.