= openKonsequenz - Alternate back-end databases (i.e. Oracle) - Statement Public Affairs
:Date: 2020-11-05
:Revision: 0.1.0
:icons:
:source-highlighter: highlightjs
:highlightjs-theme: solarized_dark
:!toc:

<<<

== Alternate back-end database - HowTo

The default database of the openKONSEQUENZ module Statement Public Affairs is the PostgreSQL database. To use other databases (i.e. Oracle), some adaptions have to be made to the build configuration and to the run configuration.

TIP: It is recommended to read the howToBuild and howToRun documentation first.

=== Build configuration

The back-end of the Statement Public Affairs module is written in Java and connects to databases with the generic JDBC connector. For Oracle we need an additional dependency referenced in the pom.xml file.

The configuration entry below is an example. Please verify that the license of the library suits your purpose.
[source,xml]
----
<dependency>
  <groupId>com.oracle.database.jdbc</groupId>
  <artifactId>ojdbc8</artifactId>
  <version>19.7.0.0</version>
</dependency>
----

=== Run configuration

The application.yml file that configures the module back-end has to be changed as follows.

Alter or add the following parameters in the *application.yml*. Other parameters should not be deleted.
[source, yml]
----
spring:
  datasource:
    url: "jdbc:oracle:thin:@192.168.56.43:1539/xe"
    username: "C##SPA_SERVICE"
    password: "spa_service"
    driver-class-name: oracle.jdbc.OracleDriver
----

Change the parameters according to your database configuration.

* The *url* parameter is of the format {jdbc_connection}@{host}:{port}/{oracle_sid}.
* The *username* and *password* are the database credentials of the module back-end user.
* The *driver-class-name* defines the connection driver.

<<<
=== Initial database configuration

In the module back-end repository you find a */deploy/db* folder that contains database initialization sql scripts.

Currently existing database initialization sql scripts:
[options="header"]
|===
|File | Database
|createDB.sql| PostgreSQL database
|createDB-Oracle.sql| Oracle database
|===

