The book "XPages Library Extension", chapter 12, page 409 provides an example 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>
The text also mentions that "in the previous example, note the use of the rcp.data strong> configuration property in the computed expression $ {rcp.data}. Connection files can take advantage of the computed properties in their definitions."
My question is: what exactly are these “calculated properties” and how are they used? I would like to save the username and password somewhere else and refer to 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:
- Managed beans
- VariableResolver
- Resource kit
- writing a connection file directly and through java.util.Properties
1 to 3 work when referenced in XPage, but not in this file. Number 4 will work if the connection file is of type "key = value". However, java.util.Properties cannot be used with XML files that do not match a specific DTD (for example, this file). And recording the entire file is not supported (in the WEB-INF section).
EDIT:
Additional Information:
- The bit above is from XPagesJDBC.nsf (from OpenNTF), and not from the image on page 409. The text on this page seems to refer to this code.
- XPagesJDBC.nsf does not contain the word "rcp.data" elsewhere, at least it does not appear in the search.
- The JDBC connection works flawlessly if the username is hard-coded.
- SQL error messages look something like this:
Unknown user: "${SettingsBean.SQLUserName}" , which, apparently, implies that this connection file is used as is.
source share