This Maven project shows the minimal configuration needed to connect to MariaDB databases using Java Database Connectivity (JDBC) without any other persistence frameworks.
Add the JDBC Driver (check the latest version):
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>LATEST</version>
</dependency>Open the connection (alternatively use try with resources to close the connection automatically):
Connection connection = DriverManager.getConnection(
"jdbc:mariadb://localhost:3306/database_name",
"user", "Password123!"
);Close the connection (if not using a try with resources block):
connection.close();- Java 21 or later. Previous versions should work (update the version in the pom.xml file).
- Apache Maven.
- MariaDB server.
- An SQL client tool like
mariadb, DBeaver, or an SQL integration for your IDE.
See the instructions here.
Run the following from the command line:
git clone git@github.com:mariadb-developers/java-quickstart.git
cd java-quickstart/jdbc/part1/
mvn package
java -jar target/jdbc-demo-1.0-SNAPSHOT.jarScreenshot of the output:
Read the tutorial or watch the video for detailed steps on how to implement this example from scratch:

