This example should be considered a milestone because it shows as you can implement DTP (Distributed Transaction Processing) with two Resource Managers (Oracle Database Server and IBM DB2 DBMS) coordinated by the LIXA Transaction Manager. It's strongly suggested you have played with the examples previously shown in this chapter (see Chapter 5, Developing C Application Programs using TX (Transaction Demarcation) interface) before starting this more complex one.
If you did not yet installed the software provided by Oracle, please refer to the official Oracle site to download the software and to pick-up the information necessary to install and configure the database. This manual does not give you information related to Oracle technology: it is assumed you already installed and configured the database.
If you did not yet installed the software provided by IBM, please refer to the official IBM site to download the software and to pick-up the information necessary to install and configure the database. This manual does not give you information related to IBM DB2 technology: it is assumed you already installed and configured the database.
The LIXA software must be configured to support the Oracle Database Server and the IBM DB2 resource managers as explained in the section called “Linking third party resource managers”. As a little hint, you should configure LIXA as below:
./configure --with-oracle=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server --with-ibmdb2=/opt/ibm/db2/V9.7
Please don't forget you must compile and install every time you re-configure.
Please follow the instructions explained
in the section called “Oracle DMBS Configuration” to set-up a running environment for Oracle Database Server
in the section called “Set-up DB2 environment” to set-up a running environment for IBM DB2 server
in the section called “Starting the state server (lixad)” to start up the LIXA state server
Prepare the client (Application Program) using the below commands (gcc command was splitted on several lines using \ to help readability, but you may use a single line):
tiian@ubuntu:~$ mkdir tmp tiian@ubuntu:~$ cd tmp tiian@ubuntu:~/tmp$ cp /opt/lixa/share/doc/lixa-X.Y.Z/examples/example4_ora_db2.c . tiian@ubuntu:~/tmp$ gcc example4_ora_db2.c $(/opt/lixa/bin/lixa-config -c -f -l -d) \ > -I/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/rdbms/public \ > -L/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib -l clntsh -l nnz10 \ > -I/opt/ibm/db2/V9.7/include -L/opt/ibm/db2/V9.7/lib32/ -ldb2 -o example4_ora_db2
Verify the executable produced by gcc:
tiian@ubuntu:~/tmp$ ldd example4_ora_db2 linux-gate.so.1 => (0xb770e000) liblixac.so.0 => /opt/lixa/lib/liblixac.so.0 (0xb76f3000) libclntsh.so.10.1 => not found libnnz10.so => not found libdb2.so.1 => /usr/lib/libdb2.so.1 (0xb61b2000) libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb6063000) libgmodule-2.0.so.0 => /usr/lib/libgmodule-2.0.so.0 (0xb605f000) libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb605b000) libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0xb6055000) librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb604c000) libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0xb5f9b000) libxml2.so.2 => /usr/lib/libxml2.so.2 (0xb5e7b000) liblixab.so.0 => /opt/lixa/lib/liblixab.so.0 (0xb5e66000) libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb5e41000) libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb5e28000) libcrypt.so.1 => /lib/tls/i686/cmov/libcrypt.so.1 (0xb5df6000) libpam.so.0 => /lib/libpam.so.0 (0xb5dec000) libdb2dascmn.so.1 => /opt/ibm/db2/V9.7/lib32/libdb2dascmn.so.1 (0xb5dbe000) libdb2g11n.so.1 => /opt/ibm/db2/V9.7/lib32/libdb2g11n.so.1 (0xb5750000) libdb2genreg.so.1 => /opt/ibm/db2/V9.7/lib32/libdb2genreg.so.1 (0xb5710000) libdb2install.so.1 => /opt/ibm/db2/V9.7/lib32/libdb2install.so.1 (0xb5705000) libdb2locale.so.1 => /opt/ibm/db2/V9.7/lib32/libdb2locale.so.1 (0xb56f2000) libdb2osse.so.1 => /opt/ibm/db2/V9.7/lib32/libdb2osse.so.1 (0xb53ec000) libdb2osse_db2.so.1 => /opt/ibm/db2/V9.7/lib32/libdb2osse_db2.so.1 (0xb537c000) libdb2trcapi.so.1 => /opt/ibm/db2/V9.7/lib32/libdb2trcapi.so.1 (0xb5369000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb5276000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb526b000) /lib/ld-linux.so.2 (0xb770f000) libpcre.so.3 => /usr/lib/libpcre.so.3 (0xb5243000) libz.so.1 => /usr/lib/libz.so.1 (0xb522e000) libuuid.so.1 => /lib/libuuid.so.1 (0xb522a000)
There are three unresolved references that can be fixed setting up
the environment properly; you can fix the environment manually or
using these scripts supplied by Oracle and IBM:
/home/db2inst1/sqllib/db2profile
and
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh
tiian@ubuntu:~$ echo $LD_LIBRARY_PATH tiian@ubuntu:~$ . /home/db2inst1/sqllib/db2profile tiian@ubuntu:~$ . /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh tiian@ubuntu:~$ echo $LD_LIBRARY_PATH /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib:/home/db2inst1/sqllib/lib32
Check again the executable:
tiian@ubuntu:~/tmp$ ldd example4_ora_db2 linux-gate.so.1 => (0xb777f000) liblixac.so.0 => /opt/lixa/lib/liblixac.so.0 (0xb7764000) libclntsh.so.10.1 => /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so.10.1 (0xb69b0000) libnnz10.so => /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libnnz10.so (0xb67aa000) libdb2.so.1 => /home/db2inst1/sqllib/lib32/libdb2.so.1 (0xb5278000) libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb511b000) libgmodule-2.0.so.0 => /usr/lib/libgmodule-2.0.so.0 (0xb5117000) libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb5113000) libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0xb510d000) librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb5104000) libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0xb5053000) libxml2.so.2 => /usr/lib/libxml2.so.2 (0xb4f33000) liblixab.so.0 => /opt/lixa/lib/liblixab.so.0 (0xb4f1e000) libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb4ef9000) libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb4ee0000) libnsl.so.1 => /lib/tls/i686/cmov/libnsl.so.1 (0xb4ec8000) libcrypt.so.1 => /lib/tls/i686/cmov/libcrypt.so.1 (0xb4e95000) libpam.so.0 => /lib/libpam.so.0 (0xb4e8b000) libdb2dascmn.so.1 => /home/db2inst1/sqllib/lib32/libdb2dascmn.so.1 (0xb4e5e000) libdb2g11n.so.1 => /home/db2inst1/sqllib/lib32/libdb2g11n.so.1 (0xb47f0000) libdb2genreg.so.1 => /home/db2inst1/sqllib/lib32/libdb2genreg.so.1 (0xb47b0000) libdb2install.so.1 => /home/db2inst1/sqllib/lib32/libdb2install.so.1 (0xb47a4000) libdb2locale.so.1 => /home/db2inst1/sqllib/lib32/libdb2locale.so.1 (0xb4791000) libdb2osse.so.1 => /home/db2inst1/sqllib/lib32/libdb2osse.so.1 (0xb448c000) libdb2osse_db2.so.1 => /home/db2inst1/sqllib/lib32/libdb2osse_db2.so.1 (0xb441c000) libdb2trcapi.so.1 => /home/db2inst1/sqllib/lib32/libdb2trcapi.so.1 (0xb4409000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb4315000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb430a000) /lib/ld-linux.so.2 (0xb7780000) libpcre.so.3 => /usr/lib/libpcre.so.3 (0xb42e3000) libz.so.1 => /usr/lib/libz.so.1 (0xb42ce000) libuuid.so.1 => /lib/libuuid.so.1 (0xb42ca000)
Set-up the necessary environment variables:
tiian@ubuntu:~/tmp$ echo $LIXA_PROFILE tiian@ubuntu:~/tmp$ export LIXA_PROFILE=ORA_DYN_DB2_DYN tiian@ubuntu:~/tmp$ echo $LIXA_PROFILE ORA_DYN_DB2_SYN
The below environment variables were set by the previous sourced script; take a look to them:
tiian@ubuntu:~/tmp$ echo $ORACLE_HOME /usr/lib/oracle/xe/app/oracle/product/10.2.0/server tiian@ubuntu:~/tmp$ echo $PATH /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/db2inst1/sqllib/bin:/home/db2inst1/sqllib/adm:/home/db2inst1/sqllib/misc:/home/db2inst1/sqllib/db2tss/bin tiian@ubuntu:~/tmp$ echo $ORACLE_SID XE
It is suggested to set the necessary environment variables in your
profile if you are going to execute the programs many times.
This is the list of the suggested variables:
LD_LIBRARY_PATH
,
LIXA_PROFILE
,
ORACLE_HOME
,
ORACLE_SID
,
PATH
.
We set LIXA_PROFILE
to value
“ORA_DYN_DB2_DYN”, looking at
/opt/lixa/etc/lixac_conf.xml
:
<profile name="ORA_DYN_DB2_DYN"> <sttsrvs> <sttsrv>local_1</sttsrv> </sttsrvs> <rsrmgrs> <rsrmgr>OracleXE_dynreg</rsrmgr> <rsrmgr>IBMDB2_stareg</rsrmgr> </rsrmgrs> </profile>
the profile references two Resource Managers: “OracleXE_dynreg” and “IBMDB2_stareg”, looking again at the config file:
<rsrmgr name="OracleXE_dynreg" switch_file="/opt/lixa/lib/switch_oracle_dynreg.so" xa_open_info="Oracle_XA+Acc=P/hr/hr+SesTm=30+LogDir=/tmp+threads=true+DbgFl=7+Loose_Coupling=true" xa_close_info="" /> <rsrmgr name="IBMDB2_dynreg" switch_file="/opt/lixa/lib/switch_ibmdb2_dynreg.so" xa_open_info="axlib=/opt/lixa/lib/liblixac.so,db=sample,tpm=lixa" xa_close_info="" />
we can discover how our application will access the resource managers [24]. Verify no (Oracle) trace file exists:
tiian@ubuntu:~/tmp$ ls -la /tmp/xa* ls: cannot access /tmp/xa*: No such file or directory
It is suggested to open three different terminals: the first one connected to “SAMPLE” DB2 database, the second one connected to Oracle database and the third one pointing to the directory where the compiled program example4_ora_db2 lives.
[IBM DB2 terminal session] |
tiian@ubuntu:~$ . /home/db2inst1/sqllib/db2profile tiian@ubuntu:~$ db2 (c) Copyright IBM Corporation 1993,2007 Command Line Processor for DB2 Client 9.7.1 You can issue database manager commands and SQL statements from the command prompt. For example: db2 => connect to sample db2 => bind sample.bnd For general help, type: ?. For command help, type: ? command, where command can be the first few keywords of a database manager command. For example: ? CATALOG DATABASE for help on the CATALOG DATABASE command ? CATALOG for help on all of the CATALOG commands. To exit db2 interactive mode, type QUIT at the command prompt. Outside interactive mode, all commands must be prefixed with 'db2'. To list the current command option settings, type LIST COMMAND OPTIONS. For more detailed help, refer to the Online Reference Manual. db2 => connect to SAMPLE Database Connection Information Database server = DB2/LINUX 9.7.1 SQL authorization ID = TIIAN Local database alias = SAMPLE db2 => |
[Oracle terminal session] |
tiian@ubuntu:~$ . /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh tiian@ubuntu:~$ sqlplus "hr/hr" SQL*Plus: Release 10.2.0.1.0 - Production on Tue May 3 21:52:06 2011 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production SQL> |
[Shell terminal session] |
tiian@ubuntu:~/tmp$ ls -la total 36 drwxr-xr-x 2 tiian tiian 4096 2011-05-03 21:53 . drwxr-xr-x 40 tiian tiian 4096 2011-05-03 21:04 .. -rwxr-xr-x 1 tiian tiian 14422 2011-05-02 21:53 example4_ora_db2 -rw-r--r-- 1 tiian tiian 11892 2011-05-02 21:52 example4_ora_db2.c |
Check the content of the Oracle table (“COUNTRIES”):
[Oracle terminal session] |
SQL> select * from COUNTRIES where COUNTRY_ID = 'RS'; no rows selected |
Check the content of the DB2 tables (“DB2INST1.ORG” and “DB2INST1.DEPT”):
[IBM DB2 terminal session] |
db2 => select * from DB2INST1.ORG where DEPTNUMB = 150 DEPTNUMB DEPTNAME MANAGER DIVISION LOCATION -------- -------------- ------- ---------- ------------- 0 record(s) selected. db2 => select * from DB2INST1.DEPT where DEPTNO='Z99' DEPTNO DEPTNAME MGRNO ADMRDEPT LOCATION ------ ------------------------------------ ------ -------- ---------------- 0 record(s) selected. |
example4_ora_db2 program accepts some arguments you can tune to experiment different transactions:
iorg
: insert a row into
“DB2INST1.ORG” table
dorg
: delete rows from
“DB2INST1.ORG” table
idept
: insert a row into
“DB2INST1.DEPT” table
ddept
: delete rows from
“DB2INST1.DEPT” table
icountries
: insert a row into
“COUNTRIES” table
dcountries
: delete rows from
“COUNTRIES” table
rollback
: force a transaction rollback (the
default behavior is commit)
Insert a row in all the tables and check the contents of the tables after the transaction execution:
[Third terminal session] |
tiian@ubuntu:~/tmp$ ./example4_ora_db2 iorg icountries idept INSERT INTO DB2INST1.ORG executed! INSERT INTO COUNTRIES executed! INSERT INTO DB2INST1.DEPT executed! COMMIT performed! |
Now you can verify the content of the tables after the transaction:
[Oracle terminal session] |
SQL> select * from COUNTRIES where COUNTRY_ID = 'RS'; CO COUNTRY_NAME REGION_ID -- ---------------------------------------- ---------- RS Repubblica San Marino 1 |
[IBM DB2 terminal session] |
db2 => select * from DB2INST1.ORG where DEPTNUMB = 150 DEPTNUMB DEPTNAME MANAGER DIVISION LOCATION -------- -------------- ------- ---------- ------------- 150 Europe 231 R&D Mojan 1 record(s) selected. db2 => select * from DB2INST1.DEPT where DEPTNO='Z99' DEPTNO DEPTNAME MGRNO ADMRDEPT LOCATION ------ ------------------------------------ ------ -------- ---------------- Z99 RESEARCH & DEVELOPMENT - E01 - 1 record(s) selected. |
With the opposite command you can remove the rows from the tables:
[Shell terminal session] |
tiian@ubuntu:~/tmp$ ./example4_ora_db2 dorg dcountries ddept DELETE FROM DB2INST1.ORG executed! DELETE FROM COUNTRIES executed! DELETE FROM DB2INST1.DEPT executed! COMMIT performed! |
and check the content of the tables again:
[Oracle terminal session] |
SQL> select * from COUNTRIES where COUNTRY_ID = 'RS'; no rows selected |
[IBM DB2 terminal session] |
db2 => select * from DB2INST1.ORG where DEPTNUMB = 150 DEPTNUMB DEPTNAME MANAGER DIVISION LOCATION -------- -------------- ------- ---------- ------------- 0 record(s) selected. db2 => select * from DB2INST1.DEPT where DEPTNO='Z99' DEPTNO DEPTNAME MGRNO ADMRDEPT LOCATION ------ ------------------------------------ ------ -------- ---------------- 0 record(s) selected. |
This sequence shows what happens trying to insert a duplicated row in a table that does not allow duplicates:
[Shell terminal session] |
tiian@ubuntu:~/tmp$ ./example4_ora_db2 iorg icountries idept INSERT INTO DB2INST1.ORG executed! INSERT INTO COUNTRIES executed! INSERT INTO DB2INST1.DEPT executed! COMMIT performed! tiian@ubuntu:~/tmp$ ./example4_ora_db2 iorg icountries idept INSERT INTO DB2INST1.ORG executed! OCIStmtExecute/Error while executing INSERT statement; ocirc = -1 ROLLBACK performed! |
Verify that table “DB2INST1.ORG” contains only one row because the second transaction was rolled back after the error occurred while inserting a duplicated row in “COUNTRIES” table:
[IBM DB2 terminal session] |
db2 => select * from DB2INST1.ORG where DEPTNUMB = 150 DEPTNUMB DEPTNAME MANAGER DIVISION LOCATION -------- -------------- ------- ---------- ------------- 150 Europe 231 R&D Mojan 1 record(s) selected. |
Remove the rows from the tables:
[Shell terminal session] |
tiian@ubuntu:~/tmp$ ./example4_ora_db2 dorg dcountries ddept DELETE FROM DB2INST1.ORG executed! DELETE FROM COUNTRIES executed! DELETE FROM DB2INST1.DEPT executed! COMMIT performed! |
We can introduce the usage of the rollback
option
to check dynamic registration behavior:
[Shell terminal session] |
tiian@ubuntu:~/tmp$ export LIXA_TRACE_MASK=0x00002000 tiian@ubuntu:~/tmp$ echo $LIXA_TRACE_MASK 0x00002000 tiian@ubuntu:~/tmp$ ./example4_ora_db2 iorg icountries idept rollback 2>&1 | grep ax_reg 2011-05-04 22:35:07.919522 [8962/3023124208] ax_reg: rmid=1, xid=0xbfe8d1f0, flags=0x0 2011-05-04 22:35:07.920026 [8962/3023124208] ax_reg: the application program has started a transaction (TX states S3); this XID '1279875137.47b3b61569764774bfc1e5f79ef725ae.818e85f29a0c09e22f0c75f89ca17658' will be returned 2011-05-04 22:35:07.920276 [8962/3023124208] ax_reg: sending 153 bytes to the server for step 8 2011-05-04 22:35:07.920527 [8962/3023124208] ax_reg/excp=7/ret_cod=0/errno=2 2011-05-04 22:35:07.921592 [8962/3023124208] ax_reg: rmid=0, xid=0xbfe8b09c, flags=0x0 2011-05-04 22:35:07.921812 [8962/3023124208] ax_reg: the application program has started a transaction (TX states S3); this XID '1279875137.47b3b61569764774bfc1e5f79ef725ae.818e85f29a0c09e22f0c75f89ca17658' will be returned 2011-05-04 22:35:07.921979 [8962/3023124208] ax_reg: sending 153 bytes to the server for step 8 2011-05-04 22:35:07.922128 [8962/3023124208] ax_reg/excp=7/ret_cod=0/errno=2 |
The second resource manager for profile
“ORA_DYN_DB2_DYN” is “IBMDB2_dynreg”
and it calls ax_reg
with
rmid=1
before the first resource manager
that's “OracleXE_dynreg” and calls
ax_reg
with rmid=0
later.
Switching to a different registration type is quite easy; we can start with dynamic registration for Oracle and static registration for IBM DB2:
[Shell terminal session] |
tiian@ubuntu:~/tmp$ export LIXA_TRACE_MASK=0x00002000 tiian@ubuntu:~/tmp$ echo $LIXA_TRACE_MASK 0x00002000 tiian@ubuntu:~/tmp$ export LIXA_PROFILE=ORA_DYN_DB2_STA tiian@ubuntu:~/tmp$ echo $LIXA_PROFILE ORA_DYN_DB2_STA tiian@ubuntu:~/tmp$ ./example4_ora_db2 iorg icountries idept rollback 2>&1 | grep ax_reg 2011-05-04 22:47:11.812256 [9122/3022382832] ax_reg: rmid=0, xid=0xbfc0f59c, flags=0x0 2011-05-04 22:47:11.813114 [9122/3022382832] ax_reg: the application program has started a transaction (TX states S3); this XID '1279875137.a74508954f774509a939ad9580bca2b8.03460325a8fe89a8c8134b6dea4b782e' will be returned 2011-05-04 22:47:11.813631 [9122/3022382832] ax_reg: sending 153 bytes to the server for step 8 2011-05-04 22:47:11.814037 [9122/3022382832] ax_reg/excp=7/ret_cod=0/errno=2 tiian@ubuntu:~/tmp$ ./example4_ora_db2 iorg icountries idept rollback 2>&1 | grep xa_start 2011-05-04 22:47:38.081183 [9126/3022632688] lixa_xa_start [...] 2011-05-04 22:47:38.124749 [9126/3022632688] lixa_xa_start: resource manager # 0 registers dynamically, skipping... 2011-05-04 22:47:38.125154 [9126/3022632688] lixa_xa_start: xa_start_entry(xid, 1, 0x0) = 0 2011-05-04 22:47:38.125330 [9126/3022632688] lixa_xa_start: sending 210 bytes to the server for step 24 2011-05-04 22:47:38.125654 [9126/3022632688] lixa_xa_start/excp=10/ret_cod=0/errno=2 |
Oracle is defined as the first resource manager and calls
ax_reg
using rmid=0
.
IBM DB2 is defined as the second resource manager and its
xa_start
function is called
from the LIXA transaction manager using rmid=1
.
The LIXA Transaction Manager skips the first resource manager because it is configured for dynamic registration.
Using static registration for Oracle and dynamic registration for IBM DB2 is easy as well:
[Shell terminal session] |
tiian@ubuntu:~/tmp$ export LIXA_PROFILE=ORA_STA_DB2_DYN tiian@ubuntu:~/tmp$ echo $LIXA_PROFILE ORA_STA_DB2_DYN tiian@ubuntu:~/tmp$ ./example4_ora_db2 iorg icountries idept rollback 2>&1 | grep ax_reg 2011-05-04 22:57:37.235541 [9346/3023226608] ax_reg: rmid=1, xid=0xbfcf8880, flags=0x0 2011-05-04 22:57:37.236410 [9346/3023226608] ax_reg: the application program has started a transaction (TX states S3); this XID '1279875137.1bf330d60c0442e4b61539214a413ecb.79fecb55351db58295ebf99c9bf09a70' will be returned 2011-05-04 22:57:37.236859 [9346/3023226608] ax_reg: sending 153 bytes to the server for step 8 2011-05-04 22:57:37.237581 [9346/3023226608] ax_reg/excp=7/ret_cod=0/errno=2 tiian@ubuntu:~/tmp$ ./example4_ora_db2 iorg icountries idept rollback 2>&1 | grep xa_start 2011-05-04 22:58:10.258562 [9350/3022706416] lixa_xa_start [...] 2011-05-04 22:58:10.296182 [9350/3022706416] lixa_xa_start: xa_start_entry(xid, 0, 0x0) = 0 2011-05-04 22:58:10.296448 [9350/3022706416] lixa_xa_start: resource manager # 1 registers dynamically, skipping... 2011-05-04 22:58:10.296625 [9350/3022706416] lixa_xa_start: sending 210 bytes to the server for step 24 2011-05-04 22:58:10.296990 [9350/3022706416] lixa_xa_start/excp=10/ret_cod=0/errno=2 |
Now the roles of Oracle and IBM DB2 swapped. As a final example you can try the static registration for Oracle and IBM DB2 too:
[Shell terminal session] |
tiian@ubuntu:~/tmp$ export LIXA_PROFILE=ORA_STA_DB2_STA tiian@ubuntu:~/tmp$ echo $LIXA_PROFILE ORA_STA_DB2_STA tiian@ubuntu:~/tmp$ ./example4_ora_db2 iorg icountries idept rollback 2>&1 | grep ax_reg tiian@ubuntu:~/tmp$ ./example4_ora_db2 iorg icountries idept rollback 2>&1 | grep xa_start 2011-05-04 23:00:27.871131 [9356/3022927600] lixa_xa_start [...] 2011-05-04 23:00:27.917087 [9356/3022927600] lixa_xa_start: xa_start_entry(xid, 0, 0x0) = 0 2011-05-04 23:00:27.918251 [9356/3022927600] lixa_xa_start: xa_start_entry(xid, 1, 0x0) = 0 2011-05-04 23:00:27.918741 [9356/3022927600] lixa_xa_start: sending 281 bytes to the server for step 24 2011-05-04 23:00:27.919389 [9356/3022927600] lixa_xa_start/excp=10/ret_cod=0/errno=2 |
No resource manager calls ax_reg
with this
configuration: this is exactly what's expected.
As a final check, we can verify all the tables have no rows:
[Oracle terminal session] |
SQL> select * from COUNTRIES where COUNTRY_ID = 'RS'; no rows selected |
[IBM DB2 terminal session] |
db2 => select * from DB2INST1.ORG where DEPTNUMB = 150 DEPTNUMB DEPTNAME MANAGER DIVISION LOCATION -------- -------------- ------- ---------- ------------- 0 record(s) selected. db2 => select * from DB2INST1.DEPT where DEPTNO='Z99' DEPTNO DEPTNAME MGRNO ADMRDEPT LOCATION ------ ------------------------------------ ------ -------- ---------------- 0 record(s) selected. |
Congratulations! You have just completed a full discovery of a Distributed Transaction Processing example with a simple Application Program, LIXA Transaction Manager and two widespread Resource Managers: Oracle Database Server and IBM DB2 DBMS.
[24]
The content of xa_open_info
string is
described in chapter 15 "Developing Applications with Oracle XA"
of the "Oracle Database Application Developer's Guide"
manual; please refer to the documentation published by
Oracle Corporation for further details.
The content of xa_open_info
string is
documented at IBM Infocenter: search the string
“xa_open string formats” in the documentation
relevant to your installed version; this is a link
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.admin.2pc.doc/doc/r0005080.html
but it may change in the future.