4

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>

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:

  1. Managed beans
  2. VariableResolver
  3. Resource bundle
  4. writing the connection file directly and through java.util.Properties

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).

EDIT:

Some additional information:

  • 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".
Lauri Laanti
  • 948
  • 7
  • 11
  • I think I blogged about it some months ago. I am also missing the feature to dynamically set user and pass for the connection for e.g. a configuration document. http://oliverbusse.notesx.net/hp.nsf/tags.xsp?query=jdbc – Oliver Busse Sep 07 '15 at 17:33

2 Answers2

1

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.

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:

the Lotus Expeditor platform uses the System property rcp.data to identify the location >of the workspace.

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

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:

The placeholder ${env.”system environmental variable”} is used to specify the use of a >system environmental variable.

The placeholder ${prop.”rcplauncher_property”} is used to specify the use of a property >from rcplauncher.properties.

So perhaps you could put credentials in rcplauncher.properties and refer to them via ${prop.*} variables.

Community
  • 1
  • 1
charles ross
  • 570
  • 4
  • 15
  • Very interesting! Unfortunately the rcplauncher.properties file appears to be client-side only. Sysenv values would be server-side, but not NSF-specific. Clearly some research is needed. – Lauri Laanti Aug 07 '13 at 23:16
  • 1
    On the Domino server, XSP and DOTs each have such a file, eg: under Domino\data\domino\workspace\.config and Domino\data\domino\workspace-dots\.config – charles ross Aug 08 '13 at 02:28
  • I found only rcpinstall.properties there. (R8.5 and R9 standard install, no DOTS). Even then, it would be server-wide, so no help in this case. – Lauri Laanti Aug 08 '13 at 13:11
  • Typical apps using a jdbc connection would use just a single admin credential to do lookups. You mean you want to make your own additional user directory on the server, sort of simulating a single sign-on? That's a whole additional topic. – charles ross Aug 09 '13 at 13:32
  • It's a financial application, so strict rules apply. Each customer (and their customers, it's a two-tiered design) has their own MySQL database. Using same credentials (and storing them in a shared NTF) would perhaps constitute a security risk. So, current approach is storing the MySQL credentials in a NotesDocument protected be ACL and/or a reader field. - btw, really appreciate your insightful comments. – Lauri Laanti Aug 09 '13 at 20:11
0

There is a core XPages runtime fix required to remedy this. By core I mean something that cannot be fixed purely in the XPages Extension Library. Thus the fix will only be available in the next full Domino release.

Brian Gleeson - IBM
  • 2,565
  • 15
  • 21