Skip to content

Connecting to a Database

To connect Forms with a database you must use the configOverrideFiles parameter. Sample snippets have been provided, which will need to be updated with your specific details.

Note

All user names and passwords should be managed using custom secrets.

Connecting to a PostgreSQL database

The PostgreSQL jdbc driver has been included and can be found at ${server.config.dir}/lib.

configuration: 
  leap:
    . . . 
    configOverrideFiles: 
      . . .
      postgreSQLOverride: |  
        <server description="leapServer">
          <!-- Disable the hard-coded derby datasource -->
          <dataSource id="leapDerbyDatasource" jndiName="disabled" />
          <!-- Adds the jdbc library to the Forms application classpath -->        
          <library id="jdbcPostgreSQL" > 
            <fileset dir ="${server.config.dir}/lib" includes="postgresql.jar" /> 
          </library> 
          <application id="leap">
            <classloader id="leapClassloader" commonLibraryRef="jdbcPostgreSQL"/>
          </application>        
          <authData id="postgresAuthAlias" user="${db-credentials/DB_USERNAME}" password="${db-credentials/DB_USERNAME}" />  
          <dataSource id="leapPostgresDataSource" jndiName="jdbc/BuilderDataSource" containerAuthDataRef="postgresAuthAlias"> 
            <properties.postgresql  
                serverName="postgresql.acme.com"  
                databaseName="leapDB"
                portNumber="5432"
            />
            <jdbcDriver libraryRef="jdbcPostgreSQL"/> 
            <connectionManager connectionTimeout="180" maxPoolSize="100" minPoolSize="1" numConnectionsPerThreadLocal="1" /> 
          </dataSource> 
        </server>

Parent topic: Open Liberty server customizations