日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

JCO_(配置连接池)

發布時間:2025/3/20 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 JCO_(配置连接池) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、配置環境:?
1.下載sapjco3.dll插件置放在JDK、bin文件夾下?
2.下載sapjco3.jar置放工程中

二、配置訪問屬性文件?
SAPConnectionPool.properties

#sap服務器IP地址,如果是外網訪問,則在內網IP前加/H/外網IP/H/192.168.0.10 jco.client.ashost=192.168.0.10 #系統編號 jco.client.sysnr=01 #配置client jco.client.client=999 jco.client.user=likb jco.client.passwd=330330 jco.destination.pool_capacity=3 jco.destination.peak_limit=10 jco.client.lang=ZH
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

三、封裝獲取鏈接池鏈接Java類,以便接口使用時調用?
SAPConnectionPool類:

@Service("SAPConnectionPool") public class SAPConnectionPool {private static final String SAP_CONN="SAP_CONN";public static JCoDestination getSAPDestination(){try {JCoDestination dest = JCoDestinationManager.getDestination(SAP_CONN);return dest;} catch (JCoException ex) {System.out.println(ex);System.out.println("連接失敗");//重新連接return RegetJocodestination();} } /****** @author :QZC* @createDate :2015年8月27日 上午11:08:47* 函數功能描述:重新獲取JCODestination* @return*****/public static JCoDestination RegetJocodestination(){try{Properties properFile = new Properties();ClassLoader cl=Thread.currentThread().getContextClassLoader();String filePath=cl.getResource("").toString()+"SAPConnectionPool.properties";filePath=filePath.replace("file:", "");FileInputStream inputFile = new FileInputStream(filePath);properFile.load(inputFile);inputFile.close();Properties connectProperties = new Properties();connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, properFile.getProperty("jco.client.ashost"));connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, properFile.getProperty("jco.client.sysnr"));connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, properFile.getProperty("jco.client.client"));connectProperties.setProperty(DestinationDataProvider.JCO_USER, properFile.getProperty("jco.client.user"));connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, properFile.getProperty("jco.client.passwd"));connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, properFile.getProperty("jco.destination.pool_capacity"));connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, properFile.getProperty("jco.destination.peak_limit"));connectProperties.setProperty(DestinationDataProvider.JCO_LANG, properFile.getProperty("jco.client.lang"));CustomDestinationDataProvider provider = new CustomDestinationDataProvider();provider.addDestinationProperties(SAP_CONN, connectProperties);Environment.registerDestinationDataProvider(provider);try {JCoDestination dest = JCoDestinationManager.getDestination(SAP_CONN);return dest;} catch (JCoException ex) {System.out.println(ex);System.out.println("重新連接失敗");} }catch(Exception e){e.printStackTrace();}return null; }}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61

獲取鏈接的輔助處理類:CustomDestinationDataProvider.java

public class CustomDestinationDataProvider implements DestinationDataProvider {private Map providers = new HashMap();@Overridepublic Properties getDestinationProperties(String destName) {if (destName == null)throw new NullPointerException("請指定目的名稱");if (providers.size() == 0)throw new IllegalStateException("請加入一個目的連接參數屬性給提供者");return (Properties)providers.get(destName);}// 沒有實現事件處理@Overridepublic boolean supportsEvents(){return false;}@Overridepublic void setDestinationDataEventListener(DestinationDataEventListener listener) {throw new UnsupportedOperationException();}public void addDestinationProperties(String destName, Properties provider) {providers.put(destName, provider);} }

總結

以上是生活随笔為你收集整理的JCO_(配置连接池)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。