我在这个事务中绑定websphere自己的XA数据源,执行事务没有问题的
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
h.put(Context.PROVIDER_URL, "iiop://10.80.12.124:2809/");
InitialContext ctx = new InitialContext(h);
tx = (UserTransaction) ctx.lookup("jta/usertransaction");
tx.begin();
ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("mydbxa");
conn = ds.getConnection();
PreparedStatement stmt = conn
.prepareStatement("insert into c(c.compid,c.userid) values(?,?)");
String value = String.valueOf(System.currentTimeMillis());
stmt.setString(1, value);
stmt.setString(2, value);
stmt.executeUpdate();
tx.commit();
ctx.close();