连接sap大概需要以下几步:
windows环境下执行需要:sapjco3.jar、sapjco3.dll
1、获取连接(有四种格式) 2、获取相应函数 3、入参设置(一般有三种格式的入参:一般参数、JCoStructure参数、JCoTable参数)4、执行execute()方法,获取结果 5、根据返回结果解析相应数据。
一、获取连接:
(1)主动生成配置文件
Properties connectProperties = new Properties(); connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "127.0.0.1");//IP connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, "00");//系统编号 connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "001");//客户端编号 connectProperties.setProperty(DestinationDataProvider.JCO_USER, "username");//用户名 connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, "password");//密码 connectProperties.setProperty(DestinationDataProvider.JCO_LANG, "zh");//语言 createDestinationDataFile(DESTINATION_NAME1, connectProperties); connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, "30");//最大空闲连接数 connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, "150");//最大活动连接数 createDestinationDataFile(DESTINATION_NAME2, connectProperties);//创建连接文件
//创建配置文件的方法 static void createDestinationDataFile(String destinationName, Properties connectProperties) { File destCfg = new File(destinationN