qq_38197803 2017-12-02 04:05 采纳率: 0%
浏览 5007

java JCO连接SAP时报错

Caused by: RfcException: [null]
message: Connect from SAP gateway to RFC server failed
Connection parameters: TYPE=A DEST=ABAP_AS_WITHOUT_POOL ASHOST=******** SYSNR=00 PCS=1

LOCATION SAP-Gateway on host ERPDEVAP1 / sapgw00
ERROR timeout during allocate
TIME Sat Dec 2 10:52:57 2017
RELEASE 742
COMPONENT SAP-Gateway
VERSION 2
RC 242
MODULE /bas/742_REL/src/krn/si/gw/gwr3cpic.c
LINE 2181
DETAIL no connect of TP sapdp00 from host mail.edifier.com after 20
sec
COUNTER 3

Return code: RFC_FAILURE(1)
error group: 102
key: RFC_ERROR_COMMUNICATION
  • 写回答

2条回答 默认 最新

  • 老刘2021111 2018-01-06 11:24
    关注

    废话不多说了,直接上代码吧。

     import java.util.HashMap;
    import java.util.Properties;
    
    import com.sap.conn.jco.ext.DataProviderException;
    import com.sap.conn.jco.ext.DestinationDataEventListener;
    import com.sap.conn.jco.ext.DestinationDataProvider;
    
    public class JCOProvider implements DestinationDataProvider {
    
        private HashMap<String, Properties> secureDBStorage = new HashMap<String, Properties>();
        private DestinationDataEventListener eL;
    
        @Override
        public Properties getDestinationProperties(String destinationName) {
            try
            {
                //read the destination from DB
                Properties p = secureDBStorage.get(destinationName);
    
                if(p!=null)
                {
                    //check if all is correct, for example
                    if(p.isEmpty())
                        throw new DataProviderException(DataProviderException.Reason.INVALID_CONFIGURATION, "destination configuration is incorrect", null);
                    return p;
                }
    
                return null;
            }
            catch(RuntimeException re)
            {
                throw new DataProviderException(DataProviderException.Reason.INTERNAL_ERROR, re);
            }
        }
    
        @Override
        public void setDestinationDataEventListener(
                DestinationDataEventListener eventListener) {
            this.eL = eventListener;
    
        }
    
        @Override
        public boolean supportsEvents() {
            return true;
        }
    
        //implementation that saves the properties in a very secure way
        public void changePropertiesForABAP_AS(String destName, Properties properties) {
            synchronized(secureDBStorage)
            {
                if(properties==null)
                {
                    if(secureDBStorage.remove(destName)!=null)
                        eL.deleted(destName);
                }
                else 
                {
                    secureDBStorage.put(destName, properties);
                    eL.updated(destName); // create or updated
                }
            }
        }
    }
    我有一个微信公众号,经常会分享一些Java技术相关的干货。如果你喜欢我的分享,可以用微信搜索“Java团长”或者“javatuanzhang”关注。
    
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘