Can JDBC connection files contain computed properties?

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.
+4
source share
2 answers

I assume that "rcp" is a reference to a variable object of the Rich Client Platform environment and, possibly, .data is a property pointing to the WEB-INF directory.

The documentation definitely taunts us in places with inexplicable comments like this. I see some similar materials (for example, $ {rcp. *}) In the Lotus Expeditor docs http://publib.boulder.ibm.com/infocenter/ledoc/v6r2/index.jsp?topic=/com.ibm.rcp. tools.doc.admin / updatingclientconfigurationsusingmanualupdates.html - check this. I found this little pearl there:

The Lotus Expeditor platform uses the System rcp.data property to locate> the workspace.

File f = new file (System.getProperty ("rcp.data"));

As far as I can tell, these string variables have access to the environment variables of the operating system and to the variables of the acceleration properties. How this material was grafted into the domino / XPages system has not yet been documented, but many people from the Expeditor team are now in the XSP team. Here are the tips I could find in the Expeditor documentation:

Placeholder $ {env. "system environment variable}} is used to indicate the use of the system environment variable>.

The placeholder $ {prop. "Rcplauncher_property"} is used to indicate the use of the a> property from rcplauncher.properties.

So, perhaps you can put the credentials in rcplauncher.properties and access them through the variables $ {prop. *}.

+1
source

To fix this hotfix, there is an XPages runtime patch. At the core, I mean something that cannot be fixed exclusively in the XPages extension library. Therefore, the fix will only be available in the next full Domino release.

0
source

Source: https://habr.com/ru/post/1484619/


All Articles