How to view H2 database within local Camunda Run docker instance on host?

Hi all,

I’m trying to connect to the embedded H2 database running in a local Camunda 7 Run engine docker container using IntelliJ IDEA 2022.3.2 (Ultimate Edition), but not having much luck. If I try to create a database connection to it using an Embedded connection string, then it connects and keeps the Camunda engine from writing to the same file. (I have the directory where the process-engine.mv.db lives mapped as a volume on the host machine.)

I’d expected to be able to connect via a Remote connection, but not sure how exactly to set it up. This is my current attempt:

And this is my docker-compose file:

services:
  camunda-bpm-run:
    image: camunda/camunda-bpm-platform:run-7.18.0
    container_name: camunda-bpm-run
    ports:
      - 8088:8080
      - 8082:8082
    volumes:
      - ./camunda-h2-db:/camunda/camunda-h2-dbs
      - ./camunda-local-config.yml:/camunda/configuration/default.yml
    command: ./camunda.sh --webapps --rest --swaggerui
    restart: unless-stopped

I get an EOFException when attempting to test the connection, 90067-210. When I tried as an Embedded connection with the path to my volume dir’s db file, it connects, but again, the Camunda engine can’t write to it then.

How can I get both to work at the same time?

Hello @DaveyStones ,

to make the h2 file writeable, add :rw to the end of the volume mapping:

Jonathan

Hi Jonathan,

Read-write is the default mode for volume mappings. It’s not that the embedded H2 db inside the Camunda container cannot write to that location, but that when attempting to connect to the H2 db using an “embedded” mode in the IntelliJ connection settings, it seems to just read the file itself and ends up corrupting the file such that Camunda can no longer use it.

I was hoping to avoid establishing a connection to the host file directly by using a Remote connection to the embedded H2 database in the Camunda container. I was hoping someone could help me configure the datasource connection for IntelliJ to accomplish that, and expose any ports that needed exposing in the docker-compose file.

Thanks!

Hi @DaveyStones,

in Spring Boot, you can enable a web console for the H2 database and apply your SQL statements there.

spring.h2.console.enabled=true

Afterwards, go to http://localhost:8080/h2-console

Hope this helps, Ingo

3 Likes

Hi Ingo,

That did work, I am able to view the H2 console with the Camunda tables available. So thank you for that!

However, I am still hoping to find a way to allow a host SQL client to be able to connect to the H2 database in the Camunda Run docker container. Is there a way to do that similar to how the connection is set up on the H2 console? Do I use the same connection string as the H2 console in the host SQL client (ie. IntelliJ Database)?

Thanks again for all your help!

NOTE: I did also have to add the following property to get the H2 console to work:

spring.h2.console.settings.web-allow-others=true
1 Like

Hi @DaveyStones,

I remember vaguely that we managed to start the H2 database as a separate Java process with TCP enabled and connect to the database via JDBC from a JDBC client some time ago. H2 docs calls this “Server mode”.

A quick look at the features on their website (Features) showed a section about “Mixed mode”. Maybe this is what you want.

Hope this helps, Ingo

2 Likes