从会话中获取服务器名称 [英] Getting the Server Name from the session
问题描述
在服务器开发的数据库中的托管Bean中,我有以下代码:
In a managed bean that resides in a Database on the server Development I have this code:
s = ExtLibUtil.getCurrentSession();
theMap.put("Server Name", s.getServerName());
运行该命令后,当我查看theMap时,会看到服务器名称",并且值为空白.在此之后,我得到一个datbase RepID,然后尝试使用
when I look at theMap after this has run I see Server Name and the value is blank. After this I get a datbase RepID and then try to open the database by RepID with
appDB = s.getDbDirectory(null).openDatabaseByReplicaID(repID);
if (appDB.isOpen()){
theMap.put(thisKey, repID);
}else{
theMap.put("DB " + thisKey, "Is Not Open");
}
如果我在本地具有数据库的rep副本,则将其打开;如果删除本地副本,则打开将失败.如果我将行更改为:
if I have a rep copy of the database locally it opens it, if I remove the local Replica the open fails. If I change the line to:
appDB = s.getDbDirectory("Development").openDatabaseByReplicaID(repID);
正确的appDB打开.因此,会话似乎认为它在本地运行,因为它为服务器名返回null.这真的很奇怪,我错过了什么吗?目前,我只是在getDbDirectory中对服务器名称进行了硬编码,但在现实世界中无法使用.
the proper appDB opens. So it looks like the session thinks it is running locally because it return null for the server name. This is really strange, am I missing something? For the moment i have just hard coded the server name in the getDbDirectory but that wont work in the real world.
推荐答案
这是XPiNC吗?除非您已将应用程序属性设置为在服务器上运行基于服务器的XPages",否则这将认为数据库在本地运行.
Is this XPiNC? That would consider the database to be running locally unless you've set the application property "Run server-based XPages on server"
这篇关于从会话中获取服务器名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!