473,544 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DB2 and ORACLE in XA transaction

Hi!

I'm using DB2 database on one server and ORACLE database on the second one.
I want to move some data from ORACLE database to DB2 database and update
some columns on ORACLE database so I know what rows were transfered. I'd
like to do this in a distributed XA transaction and Java. :)
How is this possible ?

Best regards,
Kovi
--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Apr 24 '07 #1
19 4012
Gregor Kovač wrote:
Hi!

I'm using DB2 database on one server and ORACLE database on the second
one. I want to move some data from ORACLE database to DB2 database and
update some columns on ORACLE database so I know what rows were
transfered. I'd like to do this in a distributed XA transaction and Java.
:) How is this possible ?
I'm not sure what your question is. My answer would be: open one XA
transaction to DB2, another one to Oracle, do the operations you want to
do, then perform a two-phase commit.

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Apr 24 '07 #2
Knut Stolze wrote:
Gregor Kovač wrote:
>Hi!

I'm using DB2 database on one server and ORACLE database on the second
one. I want to move some data from ORACLE database to DB2 database and
update some columns on ORACLE database so I know what rows were
transfered. I'd like to do this in a distributed XA transaction and Java.
:) How is this possible ?

I'm not sure what your question is. My answer would be: open one XA
transaction to DB2, another one to Oracle, do the operations you want to
do, then perform a two-phase commit.
Or alternatively purchase Oracle's Heterogeneous Services (formerly
Transparent Gateway). But without version information you are asking
people to shoot in the dark.
--
Daniel A. Morgan
University of Washington
da******@x.wash ington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Apr 24 '07 #3
Knut Stolze wrote:
Gregor Kovač wrote:
>Hi!

I'm using DB2 database on one server and ORACLE database on the second
one. I want to move some data from ORACLE database to DB2 database and
update some columns on ORACLE database so I know what rows were
transfered. I'd like to do this in a distributed XA transaction and Java.
:) How is this possible ?

I'm not sure what your question is. My answer would be: open one XA
transaction to DB2, another one to Oracle, do the operations you want to
do, then perform a two-phase commit.
Thanks for you answer. Maybe I was a bit unclear.
On one server I have an ORACLE database (don't know what version, yet :)) ).
One another I have DB2 v9.1. Now I want to move data from ORACLE to DB2 and
from DB2 to ORACLE. Using distributed transactions would allow me to do
commit/rollback on both ends, right? I'm using Java and don't know how to
do it (yet). :))
Now I have something like this:
// Open connection to ORACLE
Connection oracleConn = DriverManager.g etConnection(.. ..);
oracleConn.seta utoCommit(false );
// Open connection to DB2
Connection db2Conn = DriverManager.g etConnection(.. ..);
db2Conn.setauto Commit(false);

// select data from DB2
ResultSet rs = db2Conn.createS tatement().exec uteQuery("SELEC T * FROM
TABLE1");
while (rs.next() == true)
{
// insert data into ORACLE
// update some rows in DB2
}

db2Conn.commit( ); // 1
oracleConn.comm it(); // 2
In this example these is an error since commit to db2Conn (1) and be
performed and commit to oracleConn (2) can fail and I end up with data I
don't want to have. :))

I'm curious how to do the XA transactions? Do I have to use something like
DriverManager.g etXAConnection( ) ?

Best regards,
Kovi

--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Apr 25 '07 #4
On Wed, 25 Apr 2007, Gregor Kova~M wrote:
Knut Stolze wrote:
>Gregor Kovač wrote:
>>Hi!

I'm using DB2 database on one server and ORACLE database on the second
one. I want to move some data from ORACLE database to DB2 database and
update some columns on ORACLE database so I know what rows were
transfered. I'd like to do this in a distributed XA transaction and Java.
:) How is this possible ?

I'm not sure what your question is. My answer would be: open one XA
transaction to DB2, another one to Oracle, do the operations you want to
do, then perform a two-phase commit.

Thanks for you answer. Maybe I was a bit unclear.
On one server I have an ORACLE database (don't know what version, yet :)) ).
One another I have DB2 v9.1. Now I want to move data from ORACLE to DB2 and
from DB2 to ORACLE. Using distributed transactions would allow me to do
commit/rollback on both ends, right? I'm using Java and don't know how to
do it (yet). :))
Now I have something like this:
// Open connection to ORACLE
Connection oracleConn = DriverManager.g etConnection(.. ..);
oracleConn.seta utoCommit(false );
// Open connection to DB2
Connection db2Conn = DriverManager.g etConnection(.. ..);
db2Conn.setauto Commit(false);

// select data from DB2
ResultSet rs = db2Conn.createS tatement().exec uteQuery("SELEC T * FROM
TABLE1");
while (rs.next() == true)
{
// insert data into ORACLE
// update some rows in DB2
}

db2Conn.commit( ); // 1
oracleConn.comm it(); // 2
In this example these is an error since commit to db2Conn (1) and be
performed and commit to oracleConn (2) can fail and I end up with data I
don't want to have. :))

I'm curious how to do the XA transactions? Do I have to use something like
DriverManager.g etXAConnection( ) ?

Best regards,
Kovi

Hi,
You would need to use the jdbc calls for XA, you can look
them up in the manuals. You will have other problems though,
if you do this, then you will be playing the role of TM,
which, if your application is serious and not a simple toy,
then playing this role is quite a lot of work as you need to
keep track of transaction id's, server responses, etc in a
reliable way, just to ensure correctness in case one or both
of the databases go down, and transactions are not left
pending.

OR, you could just use DB2's federated capability to do what
you want. I've used it between oracle and db2 and it works
fine. It takes care of the TM role for you, and you need no
programming, just some configuration steps, then access db2
through jdbc as if it was a single database and forget about
multiple databases.

Its a separately licensed feature, not sure if you can
afford it, but would definitely save you lots of work.

Michael
Apr 25 '07 #5
On Apr 24, 5:08 am, Gregor Kovač <gregor.ko...@m ikropis.siwrote :
I'm using DB2 database on one server and ORACLE database on the second one.
I want to move some data from ORACLE database to DB2 database and update
some columns on ORACLE database so I know what rows were transfered. I'd
like to do this in a distributed XA transaction and Java. :)
How is this possible ?
One way is to use Federation. The NET8 wrapper for Oracle supports XA,
and the SQL would be simple if your Oracle tables are mapped into the
DB2 database as Nicknames.

http://publib.boulder.ibm.com/infoce...iyfqtpc01.html

Harold Lee
ha*****@us.ibm. com

Apr 25 '07 #6
On Apr 24, 5:08 am, Gregor Kovač <gregor.ko...@m ikropis.siwrote :
I'm using DB2 database on one server and ORACLE database on the second one.
I want to move some data from ORACLE database to DB2 database and update
some columns on ORACLE database so I know what rows were transfered. I'd
like to do this in a distributed XA transaction and Java. :)
How is this possible ?
Another option is to use DB2 Federation to create a nickname in the
DB2 database for the Oracle table(s). The NET8 wrapper supports XA for
two phase commit:

http://publib.boulder.ibm.com/infoce...iyfqtpc01.html

This would make your SQL very simple because it would be the same as
moving rows around within a DB2 database.

Harold Lee
ha*****@us.ibm. com

Apr 25 '07 #7
You can also do this from the other direction - use heterogeneous
services from the Oracle database to copy the rows from Oracle to DB2
and then update the Oracle rows.

See
http://download-west.oracle.com/docs....htm#sthref343

Heterogeneous Services are included for free in all Oracle databases
from Oracle8i onwards, but they use ODBC as the comm layer. If you want
something more performant than an ODBC connection, there are the
specific Transparent Gateways available for cost - in this case see the
DRDA one at
http://download-west.oracle.com/docs...b16218/toc.htm

Usage is the same - simply set up a DBLink (remote_db2_db) over
heterogeneous services or the DRDA Transparent Gateway and issue
something like

INSERT INTO remote_db2_tabl e@remote_db2_db SELECT column_list FROM
local_oracle_ta ble;

where you are connected to Oracle, and remote_db2_tabl e is the DB2 table
that you want to insert into on the other side of the remote_db2_db DBLink.

You could wrap this in the begin transaction/commit with an update to
the local oracle table as well.

Alternatively, the COPY command issued from SQLPlus is very efficient

COPY FROM SCOTT/TIGER@local_ora cle_db INSERT
remote_db2_tabl e@remote_db2_db USING SELECT * FROM local_oracle_ta ble;
Apr 26 '07 #8
>>On 4/25/2007 at 9:05 PM, in message
<0G************ ***@newssvr23.n ews.prodigy.net >, Mark
Townsend<ma**** *******@sbcglob al.netwrote:
You can also do this from the other direction - use heterogeneous
services from the Oracle database to copy the rows from Oracle to DB2
and then update the Oracle rows.

See
http://download-west.oracle.com/docs...2/b14232/genco
n.htm#sthref343

Heterogeneous Services are included for free in all Oracle databases
from Oracle8i onwards, but they use ODBC as the comm layer. If you want
something more performant than an ODBC connection, there are the
specific Transparent Gateways available for cost - in this case see the
DRDA one at
http://download-west.oracle.com/docs...102/b16218/toc
.htm
You seem to have a lot of Oracle knowledge. Do you have any idea on the
price of the Oracle Transparent Gateway for IBM DRDA? I am in fear of a
price similar to the IBM WebSphere Federation Server ($125,000!!!).

Frank

Apr 26 '07 #9
Frank Swarbrick wrote:
>>>On 4/25/2007 at 9:05 PM, in message
<0G************ ***@newssvr23.n ews.prodigy.net >, Mark
Townsend<ma**** *******@sbcglob al.netwrote:
>You can also do this from the other direction - use heterogeneous
services from the Oracle database to copy the rows from Oracle to DB2
and then update the Oracle rows.

See
http://download-west.oracle.com/docs...2/b14232/genco
>n.htm#sthref34 3

Heterogeneou s Services are included for free in all Oracle databases
from Oracle8i onwards, but they use ODBC as the comm layer. If you want
something more performant than an ODBC connection, there are the
specific Transparent Gateways available for cost - in this case see the
DRDA one at
http://download-west.oracle.com/docs...102/b16218/toc
>.htm

You seem to have a lot of Oracle knowledge. Do you have any idea on the
price of the Oracle Transparent Gateway for IBM DRDA? I am in fear of a
price similar to the IBM WebSphere Federation Server ($125,000!!!).

Frank
Going to store.oracle.co m and searching for "DB2" will give you a list
of products and prices. Buying from an Oracle sales rep will often save
you money. The prices I see on the site are listed in hundreds of
dollars ... not hundreds of thousands of dollars.
--
Daniel A. Morgan
University of Washington
da******@x.wash ington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Apr 26 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
40222
by: francis70 | last post by:
Hi, I have these 2 problem? Is there a way in Oracle to read UNCOMMITED data. i.e. in Oracle the normal behaviour is that a user's updates to a table are visible to other users ONLY when the user commits. But in Informix there is this thing called ISOLATION LEVELS. For example by setting the ISOLATION LEVEL to DIRTY READ, a user will...
7
8984
by: Jeff Lambert | last post by:
We have a Windows client application written in delphi that connects to Oracle 8i w/ ADO. We accumulate a lot of SQL statements in a loop and finally send the strings list to be executed. What I really need help with are the first three and the last three statements. How would I rewrite those under Oracle to make sure they have the same...
11
12669
by: Markus Breuer | last post by:
I have a question about oracle commit and transactions. Following scenario: Process A performs a single sql-INSERT into a table and commits the transaction. Then he informs process B (ipc) to read the new date. So process B starts "select ..." but does not get the previously inserted row. The timespan between commit and select is very short....
1
8199
by: Eirik Tryggeseth | last post by:
During deployment of an application using distributed transactions managed under COM+ on an Oracle 9i RAC database, we encounter situations where the load balancing mechanisms in the RAC result in that the component context in the distributed transaction (in our case two different COM components) cannot hold onto the same ODBC connection. Or...
1
4177
by: Rick | last post by:
I'm having problems with EnterpriseServices transactions running against Oracle 9iR2. I am inconsistently getting Oracle ORA-24761: Transaction Rolled Back results mid-transaction. If I start the transaction and run it against an object it might fail. If I rerun the same transaction again it might work. But on trying again it might fail. ...
4
3967
by: Abram Friesen | last post by:
Hi, I'm a developer for a software application vendor, and our application makes use of a customer-maintained Oracle 8i/9i database. We've had a customer request to support DB2 database, and I'm looking into the feasibility of migration. Our application runs on NT Server and, the DB2 database would be in some cases on a separate AIX...
42
6708
by: Paul | last post by:
Anyone know where I can find some good resources to help us choose between SQL and Oracle ( Progress Openedge as well ) . Any comments on what you would choose ?? We are creating a new Warehouse Management System which wil manage our very large inventory. Anyway comments suggestions welcome Thanks Paul
5
7533
by: ashley.ward | last post by:
I am attempting to write a program with VB 2005 Express Edition which accesses an Oracle 9 database and dumps the results of three SELECT queries into a spreadsheet file once every hour. Modifications will be being made to the database whilst this program is running. I would like the three queries to each give data relating to the same...
0
2999
by: gshawn3 | last post by:
Hi, I am having a hard time creating a Trigger to update an Oracle database. I am using a SQL Server 2005 Express database on a Win XP Pro SP2 desktop, linked to an Oracle 10g database on a remote Windows 2003 server. Both machines are on the same domain and very close physically (<1ms ping). I have set up the Oracle linked server in...
0
7373
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7389
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7717
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4930
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3427
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1848
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
993
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.