Heads up Postgresql Users

An easier way would be to set it in your Application.cfc

  1. First, you need to install the OSGi bundle (an exciting feature of Lucee 5). You do that by adding a bundle (which is a jar file with specific conventions, like the MANIFEST.MF file, etc.

Fortunately, the pgjdbc drivers are already “OSGi bundles”, so all you have to do is download the jar file from https://jdbc.postgresql.org/download.html and save it to your {lucee-server}/bundles directory.

Go to the Lucee Admin and click on Bundle (jar) to verify that Lucee “sees” the new bundle:

  1. Create a PostgreSQL Datasource with the the current driver, and go to Edit Datasource and scroll all the way to the bottom, where you can find a snippet that you can use in Application.cfc; It will look something like this (with your settings of database name, username, and password:

  1. Copy the snippet and paste it in the body (i.e. not inside any function) of Application.cfc
    this.datasources["pgjdbc"] = {
          class: 'org.postgresql.Driver'
        , bundleName: 'org.lucee.postgresql'
        , bundleVersion: '8.3.0.jdbc4'
        , connectionString: 'jdbc:postgresql://localhost:5432/<DATABASE-NAME>'
        , username: '<USERNAME>
        , password: "<PASSWORD>"
    };
  1. Update the snippet to reflect the new bundle’s name and version (I’m using the jdbc42 edition for Java 1.8, if you use a different one then check the bundle symbolic name inside the Jar in META-INF/MANIFEST.MF:
        , bundleName: 'org.postgresql.jdbc42'
        , bundleVersion: '9.4.1210'
  1. Test your connection with:
    <cfdbinfo name="qDbInfo" type="version">
    <cfdump eval="qDbInfo">

It should look something like this:

Igal


_MODERATOR: Hmm… for some reason this didn’t quite make it across in the migration from Redirecting to Google Groups

1 Like