最近在使用PB+Easerver做些開發,需要程式動態取得所有的Connection Cache,幾經周轉未果,今翻書偶得一代碼,雖不是順手
拿來可用,但其中思想正是所求,稍作修改后一試,果不其然......
現在此作個記錄,以便日后查詢.
//此功能需要使用到Jaguar/Repository接口.
repository px_repos
properties px_cacheprops
view px_cacheview
string ls_cache='',ls_return=''
integer i,j
integer li_numcaches=0
repositoryexception lex_error
lex_error = create repositoryexception
its.CreateInstance(px_repos,"Jaguar/Repository")
try
px_cacheview = px_repos.items("ConnCache","")
for i=UpperBound(px_cacheview.item) to 1 step -1
ls_cache = px_cacheview.item[i].item[2]
px_cacheprops = px_repos.lookup("ConnCache",ls_cache)
for j = Upperbound(px_cacheprops.item) to 1 step -1
IF px_cacheprops.item[j].name =
"com.sybase.jaguar.conncache.conlibname" then
if mid(upper(px_cacheprops.item[j].value),1,3)='OCI' THEN
ls_return = ls_return+'~r~n'+upper(ls_cache)+'~tN'
end if
exit
end if
end for
next
return mid(ls_return,3)
Catch(lookuperror le)
// lex_error.reason = le.reason
throw lex_error
catch (throwable t)
// lex_error.reason=t.getmessage()
throw lex_error
end try
本文介绍了一种使用PB+Easerver动态获取所有ConnectionCache的方法。通过利用Jaguar/Repository接口,作者实现了对连接缓存的遍历,并筛选出了特定类型的连接信息。
1602

被折叠的 条评论
为什么被折叠?



