ecology调用SAPRFC接口的第一种写法(不生成配置文件)

RFC第一种写法:不生成配置文件,直接连接

java 复制代码
package com.kaka.workflow.utils;

import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoDestinationManager;
import com.sap.conn.jco.ext.DestinationDataEventListener;
import com.sap.conn.jco.ext.DestinationDataProvider;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.Properties;
  class ConnSAPProperties implements DestinationDataProvider {
    public Properties getDestinationProperties(String destinationName) {
        Properties properties = new Properties();
        properties.setProperty(DestinationDataProvider.JCO_ASHOST, "IP地址");
        properties.setProperty(DestinationDataProvider.JCO_SYSNR, "编号");
        properties.setProperty(DestinationDataProvider.JCO_CLIENT, "客户端");
        properties.setProperty(DestinationDataProvider.JCO_USER, "账户名");
        properties.setProperty(DestinationDataProvider.JCO_PASSWD, "密码");
        properties.setProperty(DestinationDataProvider.JCO_LANG, "ZH");
        return properties;
    }
    public void setDestinationDataEventListener(DestinationDataEventListener eventListener) {}
    public boolean supportsEvents() { return false; }
}

/***
* @MethodName: ConnSAP
* @Description: 连接SAP
* @Param:
* @return:
* @Author: kaka
* @Date: 2023/9/18 17:33
*/
public class ConnSAP {
    private static Log log = LogFactory.getLog(ConnSAP.class);

    public static JCoDestination Connect() {
        ConnSAPProperties provider = new ConnSAPProperties();
        com.sap.conn.jco.ext.Environment.registerDestinationDataProvider(provider); //实例化
        JCoDestination destination = null;
        try {
            destination = JCoDestinationManager.getDestination("ABAP_AS_POOLED");
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("provider>>"+provider);
        return destination;
    }

    public static void main(String[] args) {
        JCoDestination connect = ConnSAP.Connect();
        System.out.println("connect>>>>>"+connect);
    }

}

运行结果:成功了>>>

相关推荐
天使day17 小时前
SpringMVC
java·spring·java-ee
寻找沙漠的人19 小时前
理解JVM
java·jvm·java-ee
寻找沙漠的人19 小时前
JavaEE 导读与环境配置
java·spring boot·java-ee
Theodore_10221 天前
3 需求分析
java·开发语言·算法·java-ee·软件工程·需求分析·需求
神的孩子都在歌唱1 天前
Java 和 J2EE 有什么不同?
java·开发语言·java-ee
程序员大金2 天前
基于SSM+Vue的个性化旅游推荐系统
前端·vue.js·mysql·java-ee·tomcat·mybatis·旅游
Ttang232 天前
Tomcat原理(4)——尝试手动Servlet的实现
java·开发语言·servlet·java-ee·tomcat·intellij-idea
daiyang123...3 天前
JavaEE 【知识改变命运】06 多线程进阶(1)
java·java-ee