From Fedora Project Wiki

Article about the mariadb-java-client package

Connector releases

mariadb-java-client 2.2.2 - current (F28, Rawhide)
mariadb-java-client 2.1.2 - (F27)



  • java-headless >= 1:1.8

Example usage

Install packages:

dnf install mariadb-java-client java-1.8.0-openjdk-devel

If you want to test this example against a local database, you also need to have it installed and started.

dnf install mariadb-server
systemctl start mariadb

Create file with content:
( Note: the password is empty by default )

import java.sql.*;

public class JavaMysqlSelectExample

  public static void main(String[] args) throws Exception
    // Ensure we have mariadb Driver in classpath

    // create our mysql database connection
    String host = "localhost";
    String dbname = "information_schema";
    String url = "jdbc:mariadb://" + host + "/" + dbname;
    String username = "root";
    String password = "";
    Connection conn = DriverManager.getConnection(url, username, password);

    // our SQL SELECT query. 
    // if you only need a few columns, specify them by name instead of using "*"
    String query = "SELECT * FROM ENGINES";

    // create the java statement
    Statement st = conn.createStatement();
    // execute the query, and get a java resultset
    ResultSet rs = st.executeQuery(query);
    // iterate through the java resultset
    while (
      String engine = rs.getString("ENGINE");
      String support = rs.getString("SUPPORT");
      String comment = rs.getString("COMMENT");
      String transactions = rs.getString("TRANSACTIONS");
      String xa = rs.getString("XA");
      String savepoints = rs.getString("SAVEPOINTS");
      // print the results
      System.out.format("%s, %s, %s, %s, %s, %s\n", engine, support, comment, transactions, xa, savepoints);

Compile source:


Run code:

java -classpath /usr/lib/java/mariadb-java-client.jar:. JavaMysqlSelectExample

By default java does not include any library from your system. With option -classpath we include library /usr/lib/java/mariadb-java-client.jar, to be able to see MariaDB JDBC driver, also we have to include current directory to see our compiled code.

Example output prints list of available table engines:

ROCKSDB, YES, RocksDB storage engine, YES, YES, YES
MRG_MyISAM, YES, Collection of identical MyISAM tables, NO, NO, NO
CSV, YES, CSV storage engine, NO, NO, NO
BLACKHOLE, YES, /dev/null storage engine (anything you write to it disappears), NO, NO, NO
MyISAM, YES, MyISAM storage engine, NO, NO, NO
ARCHIVE, YES, Archive storage engine, NO, NO, NO
FEDERATED, YES, FederatedX pluggable storage engine, YES, NO, YES
InnoDB, DEFAULT, Supports transactions, row-level locking, foreign keys and encryption for tables, YES, YES, YES
Aria, YES, Crash-safe tables with MyISAM heritage, NO, NO, NO
SEQUENCE, YES, Generated tables filled with sequential values, YES, NO, YES
MEMORY, YES, Hash based, stored in memory, useful for temporary tables, NO, NO, NO


Upstream infromation and documentation