Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
619 views
in Technique[技术] by (71.8m points)

connection pooling - How to make SAP JCo stay connected

This is my current JCO example code.

public class Get_Angebot {

static String   IP="****",
        USER="*****",
        PASSWORD="*****", 
        CLIENT="100", 
        SYSNR="01",
        LANG="en"; 
public static void main(String[] args) throws JCoException {

    try {

String DESTINATION_NAME1 = "mySAPSystem";
Properties connectProperties = new Properties();
connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST,   IP);
connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR,    SYSNR);
connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT,   CLIENT);
connectProperties.setProperty(DestinationDataProvider.JCO_USER,     USER);
connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD,   PASSWORD);
connectProperties.setProperty(DestinationDataProvider.JCO_LANG,     LANG);
createDestinationDataFile(DESTINATION_NAME1,connectProperties);




JCoDestination destination = JCoDestinationManager.getDestination("mySAPSystem");
JCoFunction function = destination.getRepository().getFunction("RFC_GET_TABLE_ENTRIES");



if (function==null)
    throw new RuntimeException("Function not found in SAP.");

    function.getImportParameterList().setValue(     "MAX_ENTRIES", " ");
    function.getImportParameterList().setValue(     "TABLE_NAME", "****** ");
    JCoTable codes=function.getTableParameterList().getTable("ENTRIES");
    codes.appendRow();


    try
        {    function.execute(destination);

        }
    catch (AbapException e)
        {
            System.out.println("error moffa" + e);
            return;
        }

It works fine but it is not very efficient. For one the login data is hardcoded but that can be fixed later.The real problem is that every call takes a lot of time(10-20sec) because it has to connect to the SAP-system first before it can excute a call and it does it for each call again. How can I make it stay connected so that the following calls wont take as long ?

question from:https://stackoverflow.com/questions/65905464/how-to-make-sap-jco-stay-connected

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...