JDBC连接文件可以包含计算的属性吗? [英] Can JDBC connection files contain computed properties?
问题描述
在"XPages Extension Library"一书的第12章,第409页中,有一个JDBC连接文件的示例:
In the book "XPages Extension Library", Chapter 12, page 409 there is an example of JDBC connection file:
<jdbc>
<driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
<url>jdbc:derby:${rcp.data}\derby\XPagesJDBC;create=true</url>
<user>phil</user>
<password>phil</password>
</jdbc>
在文本中还提到在上一示例中,请注意在计算表达式$ {rcp.data}中使用配置属性 rcp.data .连接文件可以利用以下内容:定义中的计算属性."
It is also mentioned in the text that "notice in previous example the use of the configuration property rcp.data in the computed expression ${rcp.data}. The connection files can take advantage of computed properties in their definitions."
我的问题是:这些计算属性"到底是什么?如何使用它们?我想将用户名和密码存储在其他位置,并使用类似以下内容的方式引用它们:
My question is: what exactly are these "computed properties" and how are they used? I would like to store the username and password somewhere else and reference them using something like this:
<user>${SettingsBean.SQLUserName}</user>
<password>${SettingsBean.SQLPassword}</password>
但是,我无法使它正常工作.到目前为止,这是我尝试过的:
However, I cannot get this to work. Here is what I have tried so far:
- 托管豆
- VariableResolver
- 资源包
- 直接并通过java.util.Properties编写连接文件
在XPage中引用
1到3,但在此文件中不引用.如果连接文件为键=值"类型,则编号4将起作用.但是,java.util.Properties不能与不符合某个DTD的XML文件一起使用(例如该文件).并且不支持写入整个文件(在WEB-INF下).
1 through 3 work when referenced in an XPage, but not in this file. Number 4 would work, if the connection file were of the "key=value" type. However, java.util.Properties cannot be used with XML files that do not conform to a certain DTD (like this file). And writing the whole file is not supported (under WEB-INF).
一些其他信息:
- 上面的位来自XPagesJDBC.nsf(来自OpenNTF),而不是来自第409页中的图像.该页面上的文本似乎引用了此代码.
- XPagesJDBC.nsf在其他地方不包含单词"rcp.data",至少它不会出现在搜索中.
- 如果用户名经过硬编码,则JDBC连接可以正常工作.
- SQL错误消息如下所示:
Unknown user: "${SettingsBean.SQLUserName}"
似乎暗示此连接文件按原样使用.
- The bit above is from the XPagesJDBC.nsf (from OpenNTF) and not from the image in page 409. The text on that page seems to refer to this code.
- XPagesJDBC.nsf does not contain the word "rcp.data" elsewhere, at least it does not show up in search.
- The JDBC connection works flawlessly if username is hardcoded.
- The SQL error messages look something like this:
Unknown user: "${SettingsBean.SQLUserName}"
which seems to imply that this connection file is used "as-is".
推荐答案
我猜"rcp"是对Rich Client Platform环境对象变量的引用,也许.data是指向WEB-INF的属性目录.
I am guessing the "rcp" is a reference to the Rich Client Platform environment object variable, and perhaps .data is the property that points to the WEB-INF directory.
文档肯定是在嘲讽我们的地方嘲笑我们.我在Lotus Expeditor文档
The documentation definitely is taunting us in places with unexplained remarks like this. I see some similar looking stuffs ( like ${rcp.*} )in the Lotus Expeditor documents http://publib.boulder.ibm.com/infocenter/ledoc/v6r2/index.jsp?topic=/com.ibm.rcp.tools.doc.admin/updatingclientconfigurationsusingmanualupdates.html - check that out. I found this little gem there:
Lotus Expeditor平台使用系统属性rcp.data来标识工作空间的位置.
the Lotus Expeditor platform uses the System property rcp.data to identify the location >of the workspace.
文件f =新文件(System.getProperty("rcp.data"));
File f = new File( System.getProperty( "rcp.data" ) );
据我所知,这些变量字符串可以访问操作系统环境变量和Expeditor属性变量.如何将这些内容移植到Domino/XPages系统中的文件尚未记录,但是Expeditor团队中的许多人现在都在XSP团队中.这是我在Expeditor文档中可以找到的线索:
As far as I can tell, these variable strings have access to operating system environment variables, and to expeditor property variables. How this stuff got grafted into the domino/XPages system is not yet documented, but many folks in the Expeditor team are now on the XSP team. Here's the clues I could find in the Expeditor docuemntation:
占位符$ {env.系统环境变量"}用于指定>系统环境变量的使用.
The placeholder ${env."system environmental variable"} is used to specify the use of a >system environmental variable.
占位符$ {prop." rcplauncher_property"}用于指定rcplauncher.properties中的属性的使用.
The placeholder ${prop."rcplauncher_property"} is used to specify the use of a property >from rcplauncher.properties.
因此,也许您可以将凭据放入rcplauncher.properties中,并通过$ {prop.*}变量进行引用.
So perhaps you could put credentials in rcplauncher.properties and refer to them via ${prop.*} variables.
这篇关于JDBC连接文件可以包含计算的属性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!