anyLogistix
Expand
Font size

Connecting to an External Database

By default anyLogistix uses the built-in PostgreSQL database, which stores all the application data. If required you can connect anyLogistix to an external database.

To connect anyLogistix desktop edition to an external database

  1. Open the db.properties file in any editor. The default file location is C:\Users\Username\.anyLogistix3\datasource\db.properties. If the file is missing, start anyLogistix. The file will be created on the application's first launch.
    spring.datasource.type=com.zaxxer.hikari.HikariDataSource
    spring.datasource.driver-class-name=org.postgresql.Driver
    spring.datasource.url=jdbc:postgresql://localhost:5431/postgres
    spring.datasource.username=postgres
    spring.datasource.password=postgres
            
  2. Define the external database:
    spring.datasource.type=com.zaxxer.hikari.HikariDataSource
    spring.datasource.driver-class-name=org.postgresql.Driver
    spring.datasource.url=jdbc:postgresql://localhost:5431/postgres
    // Specify the path to the external database.
    spring.datasource.username=postgres
    // Specify the user's username.
    spring.datasource.password=postgres
    // Specify the user's password.
            

To connect anyLogistix Professional Server to an external database

This scenario is applicable in case of manual installation. If you are using the installer, it will guide you through the steps.

  1. Open the docker-compose.yml file in any editor.
    docker-compose.yml
    version: "3.8"
    x-common-variables: &common-variables
      POSTGRES_USER: alxpostgres
      POSTGRES_PASSWORD: alxpostgrespsw
      POSTGRES_DB: alxpostgresdb
      PGDATA: /var/lib/postgresql/data/pgdata
    services:
      backend:
        image: public.ecr.aws/f2b8i3x7/production/alx3/backend-alx:latest
        mac_address: 02:42:ac:14:00:02
        hostname: alx3_backend
        restart: unless-stopped
        environment: *common-variables
        depends_on:
          - postgres
        volumes:
          - "backend-data:/home/alx3/.anyLogistix3"
      frontend:
        image: public.ecr.aws/f2b8i3x7/production/alx3/frontend-alx:latest
        mac_address: 02:42:ac:14:00:03
        ports:
          - "80:80"
        restart: unless-stopped
        depends_on:
          - backend
      postgres:
        image: public.ecr.aws/f2b8i3x7/production/alx3/postgres:14-alpine
        mac_address: 02:42:ac:14:00:04
        restart: unless-stopped
        ports:
          - "5432:5432"
        volumes:
          - "./postgres:/var/lib/postgresql/data"
        environment: *common-variables
    volumes:
      backend-data:
        external: false
  2. Edit the file:
    • Define the external database credentials:
      x-common-variables: &common-variables
        POSTGRES_USER: postgres // Specify the user's username.
        POSTGRES_PASSWORD: postgres // Specify the user's password.
        POSTGRES_DB: external_db // Specify the name of the external database.
        PGDATA: /var/lib/postgresql/data/pgdata // Remove this line, since it is required for the local database only.
    • Specify the path to the external database by redefining the SPRING_DATASOURCE_URL:
      services:
        backend:
          image: public.ecr.aws/f2b8i3x7/production/alx3/backend-alx:latest
          mac_address: 02:42:ac:14:00:02
          hostname: alx3_backend
          restart: unless-stopped
          environment:
              <<: *common-variables
              SPRING_DATASOURCE_URL: jdbc:postgresql://10.1.100.100:1000/external_db // Specify the path to the external database
          depends_on: // Remove this line, since it is required for the local database only.
            - postgres // Remove this line, since it is required for the local database only.
          volumes:
            - "backend-data:/home/alx3/.anyLogistix3"
    • Remove the postgres section to prevent starting the container with the internal database:
      postgres: // Remove this line
          image: public.ecr.aws/f2b8i3x7/production/alx3/postgres:14-alpine // Remove this line
          mac_address: 02:42:ac:14:00:04 // Remove this line
          restart: unless-stopped // Remove this line
          ports: // Remove this line
            - "5432:5432" // Remove this line
          volumes: // Remove this line
            - "./postgres:/var/lib/postgresql/data" // Remove this line
          environment: *common-variables // Remove this line
How can we improve this article?