PDA

View Full Version : Oracle XA transaction


michel_de_lange
12-17-01, 13:03
I am trying to update an Oracle table and a JMS mesage in one global transaction, using XA. I am running Personal Oracle 8 on NT. Here is my java code, as far as Oracle is concerned:

// database stuff
String DATA_SOURCE_NAME = "jdbc:oracle:thin:"+username+"/"+password+"@"+host+":"+port+":"+sid;

oracle.jdbc.xa.client.OracleXADataSource xads = new oracle.jdbc.xa.client.OracleXADataSource();

xads.setDataSourceName("oracle.jdbc.xa.client.OracleXADataSource");
xads.setURL(DATA_SOURCE_NAME);
javax.sql.XAConnection conn = xads.getXAConnection("SYSTEM","MANAGER");
javax.transaction.xa.XAResource xaResourceDB = conn.getXAResource();
c = conn.getConnection();



//create two xids for two transaction branches.
//the xid includes GlobalTransactionID and branchQualifier
//the GlobalTransactionID are same for two branches,
//but the branchQualifier are different

javax.transaction.xa.Xid xidJMS =
new progress.message.xa.XidImpl("aGlobalTxn", "JMSbranch");
javax.transaction.xa.Xid xidDB =
new progress.message.xa.XidImpl("aGlobalTxn", "DBbranch");

//mark the begin of the unit work in the global transaction
xaResourceDB.start(xidDB, XAResource.TMNOFLAGS);
// I never get here.
xaResourceSend.start(xidJMS, XAResource.TMNOFLAGS);



The code gets as far as starting the xaResourceDB, and there it fails with a nullpointer exception. This is the error message

RA-06512: in "SYS.JAVA_XA", regel 0
ORA-06512: in regel 1

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:114)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:2 08)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:542)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol .java:1311)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TT C7Protocol.java:738)
at oracle.jdbc.driver.OracleStatement.executeNonQuery (OracleStatement.java:1313)
at oracle.jdbc.driver.OracleStatement.doExecuteOther( OracleStatement.java:1232)
at oracle.jdbc.driver.OracleStatement.doExecuteWithBa tch(OracleStatement.java:1353)
at oracle.jdbc.driver.OracleStatement.doExecute(Oracl eStatement.java:1760)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTi meout(OracleStatement.java:1805)
at oracle.jdbc.driver.OraclePreparedStatement.execute Update(OraclePreparedStatement.java:320)
at oracle.jdbc.driver.OraclePreparedStatement.execute (OraclePreparedStatement.java:364)
at oracle.jdbc.xa.client.OracleXAResource.start(Oracl eXAResource.java:102)
at openjms.examples.client.console.XASender.sendAndUp date(XASender.java:115)
at openjms.examples.client.console.XASender.main(XASe nder.java:204)
oracle.jdbc.xa.OracleXAException
at oracle.jdbc.xa.OracleXAResource.checkError(OracleX AResource.java:467)
at oracle.jdbc.xa.client.OracleXAResource.start(Oracl eXAResource.java:122)
at openjms.examples.client.console.XASender.sendAndUp date(XASender.java:115)
at openjms.examples.client.console.XASender.main(XASe nder.java:204)

Does anyone know what I am doing wrong? Your help is much appreciated.

Michel de Lange

chandra_babu
07-24-02, 03:46
Hi
You cannot use XA with JMS

Best Regards
Rajesh

michel_de_lange
07-29-02, 18:13
Hello,

Thank you for your response, although I had forgotten I had posted the question. Anyway, you can use XA with JMS. I did get this to work in the end, but not using an external transaction manager. I can't quite remember exactly, but the trick was that you got an OracleXid, instead of a Xid. Something along those lines.
The JMS bit was never a problem.

Cheers, and thank you all the same,

Michel

chandra_babu
07-29-02, 22:55
Hi
Can u send the exact code for this ... in bea website it has been said that we cannot use XA dirver.
http://edocs.bea.com/wls/docs61/faq/jms.html

michel_de_lange
07-30-02, 02:21
Hi,

Sorry, but I don't work on that project anymore. I don't have the code. I just remember it did work in the end. I don't see what the BEA website would have to do with it though.

Best regards,


Michel

chandra_babu
07-30-02, 03:38
Thanks