java-quickstart
java-quickstart copied to clipboard
This repository contains code samples for getting started with Java and MariaDB.
Quick Start: Java and MariaDB
This repository contains examples on how to connect to MariaDB databases using a combination of different Java libraries and frameworks.
Before you run the examples
- Make sure you have a MariaDB Server (Enterprise or Community) running. If you don't have a MariaDB server running, you can easily run one using Docker:
docker run --name mariadb --detach --publish 3306:3306 --env MARIADB_ROOT_PASSWORD='RootPassword123!' mariadb
Alternatively, you can Download and install the server directly on your OS.
- Connect to the database using MariaDB Shell:
mariadb-shell --dsn mariadb://root:'RootPassword123!'@127.0.0.1
Alternatively, you can use any database client compatible with MariaDB.
- Prepare the database schema and user as follows:
CREATE DATABASE demo;
CREATE USER 'user'@'%' IDENTIFIED BY 'Password123!';
GRANT SELECT, INSERT, UPDATE, DELETE, DROP ON demo.* TO 'user'@'%';
CREATE TABLE demo.programming_language(
pl_id INT PRIMARY KEY AUTO_INCREMENT,
pl_name VARCHAR(50) NOT NULL UNIQUE,
pl_rating INT
);
JDBC & JPA
- JDBC (Java Database Connectivity): The foundational technology used for persistence in Java.
- JPA/Hibernate: The de-facto standard for consuming databases from Java apps.
Spring Boot
- Spring Boot Data JPA: Spring-based programming model for data access on top of JPA.
- R2DBC ➚: Reactive database connectivity.
- jOOQ: Type-safe SQL queries in Java.
- MyBatis: Map SQL results to Java methods in a simple way.
Jakarta EE (Java EE)
- Jakarta EE + GlassFish: Jakarta EE is set of vendor-neutral specifications to build enterprise Java applications.
- MicroProfile + Open Liberty: An open-source community specification for Enterprise Java microservices.
Quarkus
(work in progress)