Skip to content

Quarkus: Using JPA Sample

Start Maria db in a docker container

docker-compose.yml

version: "3.7"

services:
  mariadb-svc:
    image: mariadb:10.5
    # for debugging enable access to db server
    ports:
      - 4002:3306
    volumes:
      - maria_db_data:/var/lib/mysql
    environment:
      MYSQL_DATABASE: quarkus-db
      MYSQL_USER: quarkus-user
      MYSQL_PASSWORD: quarkus-pwd
      MYSQL_RANDOM_ROOT_PASSWORD: "yes"

volumes:
  maria_db_data:

Start mariadb and cleanup old volumes

D:\dev\Quarkus\jpa-quickstart>docker-compose up
[+] Running 11/11
 - mariadb-svc Pulled                                                                                                                                                                                                                                 4.5s
   - 7b1a6ab2e44d Already exists                                                                                                                                                                                                                      0.0s
   - 034655750c88 Already exists                                                                                                                                                                                                                      0.0s
   - f0b757a2a0f0 Already exists                                                                                                                                                                                                                      0.0s
   - 4bbcce26bc5e Already exists                                                                                                                                                                                                                      0.0s
   - 04f220ee9266 Already exists                                                                                                                                                                                                                      0.0s
   - 89c8a77f7842 Already exists                                                                                                                                                                                                                      0.0s
   - d1de5652303b Already exists                                                                                                                                                                                                                      0.0s
   - 9bb0b425c606 Already exists                                                                                                                                                                                                                      0.0s
   - 9241e174f724 Already exists                                                                                                                                                                                                                      0.0s
   - 35766610697c Already exists                                                                                                                                                                                                                      0.0s
[+] Running 2/0
 - Network jpa-quickstart_default         Created                                                                                                                                                                                                     0.1s
[+] Running 3/3quickstart_maria_db_data"  Created                                                                                                                                                                                                     0.0s
 - Network jpa-quickstart_default          Created                                                                                                                                                                                                    0.1s
 - Volume "jpa-quickstart_maria_db_data"   Created                                                                                                                                                                                                    0.0s
 - Container jpa-quickstart-mariadb-svc-1  Created                                                                                                                                                                                                    0.7s
Attaching to jpa-quickstart-mariadb-svc-1
jpa-quickstart-mariadb-svc-1  | 2021-11-30 14:17:19+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.5.13+maria~focal started.
jpa-quickstart-mariadb-svc-1  | 2021-11-30 14:17:19+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
jpa-quickstart-mariadb-svc-1  | 2021-11-30 14:17:19+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.5.13+maria~focal started.
jpa-quickstart-mariadb-svc-1  | 2021-11-30 14:17:20+00:00 [Note] [Entrypoint]: Initializing database files
jpa-quickstart-mariadb-svc-1  |
jpa-quickstart-mariadb-svc-1  |

Validate Connectivity

C:\>mysql -u quarkus-user -h localhost -P 4002 quarkus-db -pquarkus-pwd
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.5.5-10.5.13-MariaDB-1:10.5.13+maria~focal mariadb.org binary distribution
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| quarkus-db         |
+--------------------+
2 rows in set (0.00 sec)

Published inQuarkus

Be First to Comment

Leave a Reply