Database Connection Configuration
This guide describes how to configure database connections for the application.
Configuration Path
Section titled “Configuration Path”All database settings are located under the following base path:
HAKOM:Persistence:Repositories:Repository:{RepositoryName}Replace {RepositoryName} with your chosen repository identifier (e.g., MainDatabase, ReportingDB).
Configuration Structure
Section titled “Configuration Structure”{RepositoryName}├─ Name (must repeat {RepositoryName})└─ Provider ├─ Type └─ Settings └─ Setting └─ {SettingName} (provider settings)Quick Start
Section titled “Quick Start”<HAKOM> <Persistence> <Repositories> <Repository Name="MainDatabase"> <Provider> <Type>postgresql</Type> <Settings> <Setting Name="Server">db.example.com</Setting> <Setting Name="Port">5432</Setting> <Setting Name="Database">myapp</Setting> <Setting Name="User ID">app_user</Setting> <Setting Name="Password">secret123</Setting> </Settings> </Provider> </Repository> </Repositories> </Persistence></HAKOM>{ "Persistence": { "Repositories": { "Repository": { "MainDatabase": { "Name": "MainDatabase", "Provider": { "Type": "postgresql", "Settings": { "Setting": { "Server": "db.example.com", "Port": 5432, "Database": "myapp", "User ID": "app_user", "Password": "secret123" } } } } } } }}HAKOM__Persistence__Repositories__Repository__MainDatabase__Name=MainDatabaseHAKOM__Persistence__Repositories__Repository__MainDatabase__Provider__Type=postgresql
HAKOM__Persistence__Repositories__Repository__MainDatabase__Provider__Settings__Setting__Server=db.example.comHAKOM__Persistence__Repositories__Repository__MainDatabase__Provider__Settings__Setting__Port=5432HAKOM__Persistence__Repositories__Repository__MainDatabase__Provider__Settings__Setting__Database=myappHAKOM__Persistence__Repositories__Repository__MainDatabase__Provider__Settings__Setting__User_ID=app_userHAKOM__Persistence__Repositories__Repository__MainDatabase__Provider__Settings__Setting__Password=secret123Configuration Elements
Section titled “Configuration Elements”Provider Configuration
Section titled “Provider Configuration”Configure the basic provider settings for your repository.
The repository itself also requires a Name (path HAKOM:Persistence:Repositories:Repository:{RepositoryName}:Name) that repeats the configuration key. In XML the Name attribute of <Repository> supplies both.
Path: HAKOM:Persistence:Repositories:Repository:{RepositoryName}:Provider
| Element | Type | Default | Required | Description |
|---|---|---|---|---|
Type |
enum |
— | ✓ | Database type. Allowed values: oracle, sqlserver, postgresql. |
Connection Settings
Section titled “Connection Settings”Configure how to connect to your database server.
Path: HAKOM:Persistence:Repositories:Repository:{RepositoryName}:Provider:Settings:Setting
Confidential values such as passwords should not be stored in clear text. Mark them with Encrypted="true" and, optionally, a Certificate name, as shown in the examples below. How to set up the certificates is described in Cryptography Configuration, and how to encrypt a value in HAKOM.Cryptography.Console.
Individual Settings
Section titled “Individual Settings”The exact parameters needed for an Oracle connection can be found in the Oracle connection string documentation.
Oracle repository connection
Section titled “ Oracle repository connection”The following fragment shows a repository entry under HAKOM:Persistence:Repositories:
<Repository Name="TSM_ORACLE"> <Provider> <Type>oracle</Type> <Settings> <Setting Name="User ID">HAKOM_TSM_TEST</Setting> <Setting Name="Data Source">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=ORCLPDB1)))</Setting> <Setting Name="Min Pool Size">0</Setting> <Setting Name="Password" Encrypted="true" Certificate="Shared Development Key">TaE+e+...</Setting> </Settings> </Provider></Repository>The exact parameters needed for a PostgreSQL connection can be found in the Npgsql connection string parameters documentation.
PostgreSQL repository connection
Section titled “ PostgreSQL repository connection”The following fragment shows a repository entry under HAKOM:Persistence:Repositories:
<Repository Name="TSM_POSTGRESQL"> <Provider> <Type>postgresql</Type> <Settings> <Setting Name="User ID">test</Setting> <Setting Name="Server">localhost</Setting> <Setting Name="Port">5433</Setting> <Setting Name="Database">dev</Setting> <Setting Name="Password" Encrypted="true" Certificate="Shared Development Key">TaE+e+...</Setting> </Settings> </Provider></Repository>The exact parameters needed for a Microsoft SQL Server connection can be found in the SqlConnection.ConnectionString documentation.
SQL Server repository connection
Section titled “ SQL Server repository connection”The following fragment shows a repository entry under HAKOM:Persistence:Repositories:
<Repository Name="TSM_SQLSERVER"> <Provider> <Type>sqlserver</Type> <Settings> <Setting Name="User ID">ZAMS</Setting> <Setting Name="Initial Catalog">HAKOM_TSM_TEST</Setting> <Setting Name="Data Source">localhost,1434</Setting> <Setting Name="Integrated Security">false</Setting> <Setting Name="MultipleActiveResultSets">True</Setting> <Setting Name="Password" Encrypted="true" Certificate="Shared Development Key">uX7qgx...</Setting> <Setting Name="TrustServerCertificate">True</Setting> </Settings> </Provider></Repository>