(Top)

Connecting Java Programs to MariaDB / MySQL databases on Linux

6 May 2025 • 6 May 2025

Introduction

This tutorial shows how to set up your Arch system with a JDBC connector so that your Java Programs can access MariaDB / MySQL Databases.

Navigation

Installation

Installing Java

Install a Java implementation preferably OpenJDK which is what I'll be using in this article.


$ sudo pacman -S jdk-openjdk

Installing MySQL

Install a MySQL implementation preferably MariaDB which is officially endorsed by Arch Linux.


$ sudo pacman -S mariadb

To enable network access which is required by jdbc connector, make sure that /etc/my.cnf.d/server.cnf has the following line commented out:


#skip-networking

Now, start the MariaDB or MySQL service . If you use Artix Linux you will also need to install init service file for example mariadb-dinit

Installing JDBC

Install a JDBC driver / connector that matches your MySQL implementation:
*AUR refers to Arch User Repository

To install an AUR package I recommend using yay AUR


$ yay -S mariadb-jdbc

To know more about installing from AUR, see further exploration section.

Testing

Further Exploration