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 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?