Documentation

Documentation versions (currently viewingVaadin 23)

You are viewing documentation for Vaadin 23. View latest documentation

Connecting to MariaDB

Use MariaDB in your Vaadin application.

MariaDB is a popular fork of the relational database MySQL. You need to install MariaDB separately before you can connect to it from your Vaadin application (you can also install MariaDB as a Docker container).

For an existing Vaadin project, you can connect to MariaDB by following these steps:

  1. Add the mariadb-java-client dependency to the pom.xml file.

    <dependency>
        <groupId>org.mariadb.jdbc</groupId>
        <artifactId>mariadb-java-client</artifactId>
        <version>3.0.5</version>
    </dependency>
  2. Add MariaDB configuration properties to the src/main/resources/application.properties file. You have to replace HOST, PORT, DB_NAME, USERNAME, PASSWORD with corresponding parameters from your MariaDB instance.

    # MariaDB Configuration
    spring.jpa.hibernate.ddl-auto=update
    spring.datasource.url=jdbc:mariadb://HOST:PORT/DB_NAME
    spring.datasource.username=USERNAME
    spring.datasource.password=PASSWORD
    spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
Caution
Avoid storing sensitive information in the project’s properties file.

It’s bad practice to store database URI, username, and passwords in the application.properties file. You should consider externalizing these properties.

343BF5D5-D993-4273-BD94-D32DE5814898