Configuring PostgreSQL

Database creation

Create a database and user

DROP DATABASE IF EXISTS okmdb;
CREATE USER openkm WITH PASSWORD '*secret*';
CREATE DATABASE okmdb WITH OWNER openkm ENCODING 'UTF8';

or from the command line 

$ createuser --pwprompt openkm
$ createdb --owner=openkm --encoding=UTF8 okmdb

More info at:

Configure your openkm.properties

This configuration property should be set before the database creation. Once the database has been initialized, don't modify it because it can damage your installation.

If your OpenKM installation has already been configured with another database, you can't switch to another database by changing this property.

Edit the file $TOMCAT_HOME/openkm.properties

The supported dialects are:

  • com.openkm.db.dialect.PostgreSQL94Dialect
  • com.openkm.db.dialect.PostgreSQL92Dialect
  • com.openkm.db.dialect.PostgreSQL9Dialect

hibernate.dialect=com.openkm.db.dialect.PostgreSQL92Dialect
hibernate.hbm2ddl=create-only

Configure Tomcat datasources

Edit the file $TOMCAT_HOME/openkm.properties and enable the resource named jdbc/OpenKMDS

spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/okmdb
spring.datasource.username=openkm
spring.datasource.password=*secret*
spring.datasource.validationQuery=SELECT 1 

Configure the values of the attributes called:

  • Username.
  • Password.
  • URL ( change to your hosts and port ).

Configure application login

Edit the file $. TOMCAT_HOME/openkm.properties

authentication.openkm.database=true

Enable native configuration parameter

Go to Administration > Configuration parameters 

native.sql.lowercase=true

Run application

As a process into OpenKM startup, the application will automatically create an empty database structure. 

Once the tables are created, OpenKM will automatically change the hibernate.hbm2ddl property from create-only to none.

Additional information

If you want to obtain the maximum performance from PostgreSQL, pgFouine will help in your task.

PostgreSQL 9.6 and upper

PostgreSQL version 9.6 and upper have changed some tables and columns of the schema. Check that you are using the correct JDBC driver.