I am not sure if I post this to JMX forum or here, hoping this is the right place. 
I've defined an Xa Oracle Datasource and I'm using UserTransaction to commit, but it 
is not happening (I am not getting any error or something) Here's the simplified code 
below (the actual code involves a distributed transaction, that's why I need to use 
UserTransaction, If I change the ut.commit() below with the m_db_conn.commit(); it 
would commit, so please don't suggest that)

      try {
  |       InitialContext iniCtx = new InitialContext();
  |       DataSource ds = (DataSource) iniCtx.lookup("java:/OracleDS/XA_TX/MyDB");
  |       UserTransaction ut = (UserTransaction) iniCtx.lookup("UserTransaction");
  |       Connection m_db_conn = ds.getConnection();
  |       m_db_conn.setAutoCommit(false);    
  |       String storedProc = "begin insert into test values 
(to_char(sysdate,'SSSSS')) ; end;";          
  |       CallableStatement update_stmt = m_db_conn.prepareCall(storedProc);
  |       ut.begin();
  |       update_stmt.execute();                
  |       ut.commit();
  |       System.out.println("{{{Insert DB}}}}");   
  |       } catch (Exception e) { System.out.println("Error testUT "+ e.getMessage()); 
}

And here's the -ds.xml file

<datasources>
  |   <xa-datasource>
  |     <jndi-name>OracleDS/XA_TX/MyDB</jndi-name>
  |     <isSameRM-override-value>false</isSameRM-override-value>  
  |     <xa-datasource-property 
name="URL">jdbc:oracle:thin:@myacme.com:1521:orcl</xa-datasource-property>    
  |     <track-connection-by-tx>true</track-connection-by-tx>
  |     
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
  |     <xa-datasource-property name="User">scott</xa-datasource-property>
  |     <xa-datasource-property name="Password">tiger</xa-datasource-property>
  |     <!-- Uses the pingDatabase method to check a connection is still valid before 
handing it out from the pool -->
  |     <!-- 
valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name
 -->
  |     <!-- Checks the Oracle error codes and messages for fatal errors -->
  |     <!-- 
exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name
 -->
  |     <!-- Oracles XA datasource cannot reuse a connection outside a transaction 
once enlisted in a global transaction and vice-versa -->
  |     <no-tx-separate-pools/>
  |   </xa-datasource>
  | 
  | </datasources>



View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3852993#3852993

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3852993


-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to