This topic explains how to configure LabKey Server to retrieve and display data from a PostgreSQL database as an external data source. This topic assumes you have reviewed the general guidance here and provides specific parameters and details for this database type.

Configure the PostgreSQL Data Source

The new external data source must have a unique JNDI name that you will use in naming the properties you will define. In the example on this page, we use "externalPgDataSource", which will appear to users defining external schemas as "externalPg". If you have more than one external PostgreSQL data source, give each a unique name with the DataSource suffix ("firstExternalPgDataSource", "secondExternalPgDataSource", etc.). Learn more here.

In the <LABKEY_HOME>/config/application.properties file, add a new section with the name of the datasource and the parameters you want to define. Provide your own <DB_NAME>, <DB_USERNAME>, and <DB_PASSWORD> where indicated:

context.resources.jdbc.externalPgDataSource.driverClassName=org.postgresql.Driver
context.resources.jdbc.externalPgDataSource.url=jdbc:postgresql://localhost:5432/<DB_NAME>
context.resources.jdbc.externalPgDataSource.username=<DB_USERNAME>
context.resources.jdbc.externalPgDataSource.password=<DB_PASSWORD>

There are additional properties you can set, as shown in the template for the main "labkeyDataSource" in the application.properties file.

driverClassName

Use this as the driverClassName:

org.postgresql.Driver

url

The url property for PostgreSQL takes this form, including the name of the database at the end:

jdbc:postgresql://localhost:5432/<DB_NAME>

validationQuery

Use "SELECT 1" as the validation query for PostgreSQL. This is the default so does not need to be provided separately for this type of external data source:

SELECT 1

Define a New External Schema

To define a new schema from this data source see Set Up an External Schema.

Related Topics

Was this content helpful?

Log in or register an account to provide feedback


previousnext
 
expand allcollapse all