Search code examples
javasql-serverjdbcxpagesxpages-extlib

How to store JDBC server, database, username and password in a notesdocument


I am using JDBC from ExtLib in my xpages application to connect to SQL and have a JDBC connection file in the Webcontent/WEB-INF/JDBC/mssql.jdbc

Looks something like this and works great

<jdbc>
  <driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
    <url>jdbc:sqlserver://server:1433;databaseName=db</url>
    <user>sa</user>
  <password></password>
</jdbc>

I have a need to make this more dynamic by storing the servername, database, username and password in a notesdocument, is this possible, if so how?

if this is not possible, Is it possible to update the JDBC file programmatically or use other features in ExtLib for making this possible?


Solution

  • We have done this at our company by copying the setup of the JDBCProvider from within the Extension Library, and modifying it so that instead of searching for configuration in xml documents, it will instead search for configuration in Notes documents in using a pre-defined View and Form.

    I've just shared it via the jdbcprovider branch in my fork of the ExtLibX project, with the hope to eventually do a pull request to get it into the official OpenNTF ExtLibX, and maybe finally into the core Extension library project.

    I have created an 'alpha' release that you can test out, or you can have a browse in the com.ibm.xsp.extlibx.core plugin to see the source code

    Here is a blog post that I have written about the first release and there is a short demo video in there as well

    http://camerongregor.com/2017/12/05/jdbcnotesdocuments/