网站开发合同付款方式,上海大型广告公司,鹤壁做网站哪家便宜,网络营销的功能有哪些要让JAVA程序能访问SAP系统#xff0c;一般通过SAP JCO接口进行通讯#xff0c;在获取到SAP的连接时需求提供一些连接参数#xff0c;这些参数在最新的 JCO 3.0 中需要被保存到一个带有扩展名.jcoDestination的文件中#xff0c;这个文件同时被保存在应用程序的安装目录中。… 要让JAVA程序能访问SAP系统一般通过SAP JCO接口进行通讯在获取到SAP的连接时需求提供一些连接参数这些参数在最新的 JCO 3.0 中需要被保存到一个带有扩展名.jcoDestination的文件中这个文件同时被保存在应用程序的安装目录中。因为这只中一个纯文本文件所有的连接参数并没有被加密这样对于公用程序可能有安全问题。要使用登陆连接更加安全可以实现自定义的 DestinationDataProvider 实现此接口只有简单的三个方法 interface DestinationDataProvider {Properties getDestinationProperties(java.lang.String destinationName);void setDestinationDataEventListener(DestinationDataEventListener eventListener);boolean supportsEvents();
} getDestinationProperties 当Java程序获取到SAP的连接时jco会从这里读取连接属性你可以编程动态的设定这些属性setDestinationDataEventListener 设置一个连接事件监听器实现一个监听器当JCO连接SAP以获得通知supportsEvents 返回是否被实现的DestinationDataProvider有事件监听器 实现一个自定义Provider: static class MyDestinationDataProvider implements DestinationDataProvider{private DestinationDataEventListener eL;private Properties ABAP_AS_properties; public Properties getDestinationProperties(String destinationName){if(destinationName.equals(ABAP_AS) ABAP_AS_properties!null)return ABAP_AS_properties;return null;//alternatively throw runtime exception//throw new RuntimeException(Destination destinationName is not available);}public void setDestinationDataEventListener(DestinationDataEventListener eventListener){this.eL eventListener;}public boolean supportsEvents(){return true;}void changePropertiesForABAP_AS(Properties properties){if(propertiesnull){eL.deleted(ABAP_AS);ABAP_AS_properties null;}else {if(ABAP_AS_properties!null !ABAP_AS_properties.equals(properties))eL.updated(ABAP_AS);ABAP_AS_properties properties;}}} 测试连接 public static void main(String[] args) throws Exception{Properties connectProperties new Properties();connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, binmain);connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, 53);connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, 000);connectProperties.setProperty(DestinationDataProvider.JCO_USER, JCOTEST);connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, JCOTEST);connectProperties.setProperty(DestinationDataProvider.JCO_LANG, en);MyDestinationDataProvider myProvider new MyDestinationDataProvider();com.sap.conn.jco.ext.Environment.registerDestinationDataProvider(myProvider);myProvider.changePropertiesForABAP_AS(connectProperties);JCoDestination ABAP_AS JCoDestinationManager.getDestination(ABAP_AS);ABAP_AS.ping();System.out.println(ABAP_AS destination is ok);} 转载于:https://www.cnblogs.com/rinack/p/8041582.html