请高手帮忙解决一下

解决方案 »

  1.   

    http://topic.csdn.net/t/20031212/11/2556060.html
      

  2.   

    不知道你问题的详细情况
    看你的标题写的是分布式事务不能调用rollback
    不知道你怎么调用的
    主事务中式可以控制其他的分布事务的
    如果你用oracle的datebaselink,创建该数据链的数据库中发起的事物是可以控制数据链引用的其他数据库中的事物的
      

  3.   

    这个能从根源上解决一下吗,怎么确定为什么要回滚呢。我看程序是tx.commit失败后报的这个,为什么会commit失败呢
      

  4.   

    我把程序贴上来大家看看。
        private BOPrimaryKeyInfo getNextPrimaryKey(int entity, int range, String tableName, String keyColName) throws DAOException {
            Vector<Object> param = new Vector<Object>(5);
            param.addElement(new Integer(entity));        if (range < 0)
                throw new RuntimeException("Can't specify a negative range : " + range);        int nextPrimaryKey = 1;
            Transaction tx = null;
            DAOResult rs = null;
            try {
                if (tm == null) {
                    logger.debug("tm is null");            
                    tx = TransactionManager.getTransaction();
                    tx.begin();
                } else {
                    logger.debug("tm is not null");              
                    tx = TransactionManager.getTxTransaction();
                }
                logger.debug("before rs");             
                rs = this.executeQuery(SELECT_AND_LOCK_PRIMARY_KEY_TABLE, param, tx);
                logger.debug("after rs");               if (rs.next()) {
                    nextPrimaryKey = rs.getInt(1);                if (!rs.wasNull()) {
                        param.removeAllElements();                    int newNextPrimaryKey = nextPrimaryKey + range;                    param.addElement(new Integer(newNextPrimaryKey));
                        param.addElement(new Integer(entity));
                        logger.debug("before update");     
                        executeUpdate(UPDATE_PRIMARY_KEY_TABLE, param, tx);
                        logger.debug("after update");     
                        if (tm == null)
                            tx.commit();
                        logger.debug("before return BOPrimaryKeyInfo entity_key");
                        return new BOPrimaryKeyInfo(entity, tableName, keyColName, nextPrimaryKey);
                    } else {
                        throw new DAOException("error happened when try to get primary key range is available");
                    }
                }
            } catch (Exception ex) {
                if (tm == null && tx != null)
                    tx.rollback();
                throw new DAOException("error happened when try to update primary key range is new " + ex);
            } finally {
                if (rs != null)
                    rs.close();
                if (tx != null)
                    tx.close();
            }
      

  5.   

    报错日志是这样的
    com.cibs.daomgr.DAOException: ((com.cibs.daomgr.Transaction) : try to Roll back error ^M
    java.sql.SQLException: Cannot call Connection.rollback in distributed transaction.  Transaction Manager will commit the resource manager when the distributed transaction is committed.