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);
    }

}

运行结果:成功了>>>

相关推荐
程序猿chen3 小时前
《JVM考古现场(十五):熵火燎原——从量子递归到热寂晶壁的代码涅槃》
java·jvm·git·后端·java-ee·区块链·量子计算
我要学编程(ಥ_ಥ)5 小时前
初始JavaEE篇 —— Mybatis-plus 操作数据库
java·java-ee·mybatis·mybatis-plus
葵野寺6 小时前
【多线程】synchronized锁升级和优化
java·开发语言·java-ee
鸽鸽程序猿20 小时前
【JavaEE】MyBatis - Plus
java-ee·mybatisplus
eternal__day1 天前
Spring Boot 快速入手
java·spring boot·后端·spring·java-ee·maven
葵野寺1 天前
【多线程】线程池
java·开发语言·java-ee·web app
SuperherRo1 天前
Web开发-JavaEE应用&ORM框架&SQL预编译&JDBC&MyBatis&Hibernate&Maven
前端·sql·java-ee·maven·mybatis·jdbc·hibernate
逸狼2 天前
【JavaEE进阶】MyBatis(4)-完善图书管理系统
数据库·java-ee·mybatis
bysjlwdx3 天前
deploy myEclipse j2ee project to server没反应
ide·java-ee·myeclipse
努力也学不会java4 天前
【MyBatis】MyBatis 操作数据库
java·数据库·spring boot·spring·java-ee·intellij-idea·mybatis