The first thing you need to do is make sure the XADataSource works outside 
JBoss.

Use IBM to help you on this.

Here is the code to test it is working:


  | package test;
  | 
  | import java.io.Serializable;
  | import java.util.Arrays;
  | import java.util.Random;
  | 
  | import javax.sql.XAConnection;
  | import javax.transaction.xa.XAResource;
  | import javax.transaction.xa.Xid;
  | 
  | import com.ibm.db2.jcc.DB2XADataSource;
  | 
  | public class Test
  | {
  |    public static void main(String[] args) throws Exception
  |    {
  |       DB2XADataSource xaDataSource = new DB2XADataSource();
  |       xaDataSource.setDataBase("zcoreinv");
  |       xaDataSource.setUser("zcoreinv");
  |       xaDataSource.setPassword("zcoreinv");
  |       xaDataSource.setPortNumber(500);
  |       xaDataSource.setServerName("localhost");
  |       xaDataSource.setDriverType(4);
  |       
  |       XAConnection xaConnection = xaDataSource.getXAConnection();
  |       XAResource xaResource = xaConnection.getXAResource();
  |       XidImpl xid = new XidImpl();
  |       xaResource.start(xid, XAResource.TMNOFLAGS);
  |    }
  | 
  |    public static class XidImpl implements Serializable, Xid
  |    {
  |       private static final long serialVersionUID = -2227021688745286343L;
  | 
  |       private static Random random = new Random();
  |       
  |       private int formatId = 876;
  | 
  |       private byte[] globalTransactionId;
  | 
  |       private byte[] branchQualifier = new byte[0];
  | 
  |       private transient String cachedToString;
  | 
  |       private transient int cachedHashCode;
  | 
  |       public XidImpl()
  |       {
  |          globalTransactionId = new byte[10];
  |          random.nextBytes(globalTransactionId);
  |       }
  | 
  |       public int getFormatId()
  |       {
  |          return formatId;
  |       }
  | 
  |       public byte[] getGlobalTransactionId()
  |       {
  |          return globalTransactionId;
  |       }
  | 
  |       public byte[] getBranchQualifier()
  |       {
  |          return branchQualifier;
  |       }
  | 
  |       public boolean equals(Object object)
  |       {
  |          if (object == null || (object instanceof Xid) == false)
  |             return false;
  | 
  |          Xid other = (Xid) object;
  |          return
  |          (
  |             formatId == other.getFormatId() && 
  |             Arrays.equals(globalTransactionId, 
other.getGlobalTransactionId()) &&
  |             Arrays.equals(branchQualifier, other.getBranchQualifier())
  |          );
  |       }
  | 
  |       public int hashCode()
  |       {
  |          if (cachedHashCode == 0)
  |          {
  |             cachedHashCode = formatId;
  |             for (int i = 0; i < globalTransactionId.length; ++i)
  |                cachedHashCode += globalTransactionId;
  |          }
  |          return cachedHashCode;
  |       }
  | 
  |       public String toString()
  |       {
  |          if (cachedToString == null)
  |          {
  |             StringBuffer buffer = new StringBuffer();
  |             buffer.append("XidImpl[FormatId=").append(getFormatId());
  |             buffer.append(" GlobalId=").append(new 
String(getGlobalTransactionId()).trim());
  |             byte[] branchQualifer = getBranchQualifier();
  |             buffer.append(" BranchQual=");
  |             if (branchQualifer == null)
  |                buffer.append("null");
  |             else
  |                buffer.append(new String(getBranchQualifier()).trim());
  |             buffer.append(']');
  |             cachedToString = buffer.toString();
  |          }
  |          return cachedToString;
  |       }
  |    }
  | }
  | 

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

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4007744
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to