Documentation

Documentation versions (currently viewingVaadin 24)

Connecting to MariaDB

How to use MariaDB in a 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 there are a few steps. First, 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>

Next, add MariaDB configuration properties to the src/main/resources/application.properties file:

# 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

You have to replace HOST, PORT, DB_NAME, USERNAME, PASSWORD with corresponding parameters from your MariaDB instance.

Caution
Don’t Store Sensitive Information in a Project’s Properties File

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

343BF5D5-D993-4273-BD94-D32DE5814898