MariaDB Connector/J


Java developers can connect to MariaDB SkySQL from their application using MariaDB Connector/J, which implements the JDBC API.

MariaDB Connector/J can be used with:

  • MariaDB Platform for Transactions

  • MariaDB Platform for Analytics

  • MariaDB Platform for Smart Transactions (HTAP)

  • MariaDB Platform for Distributed SQL


MariaDB Connector/J

Supported Versions


Programming Language


Programming Language Version

Java 11, Java 8 (Connector/J 2.7)
Java 7 (Connector/J 1.8)


JDBC 4.2 (Connector/J 2.7)
JDBC 4.1 (Connector/J 1.8)

Supports TLS


Supports Connection Pools



GNU Lesser General Public License v2.1

MariaDB Connector/J installation and connection instructions follow. Additional information on MariaDB Connector/J can be found in the Connector/J reference.

Installing MariaDB Connector/J

MariaDB Connector/J is typically installed either by using Maven or by manually downloading the JAR file.

Installing MariaDB Connector/J via Maven

To use Maven, install MariaDB Connector/J by adding the following dependency to your pom.xml file:


Depending on what features you plan to use, you may need to add some additional dependencies to pom.xml.

To use connection pools with commons-dbcp2 from Apache Commons, add the following dependency to your pom.xml file as well:


Installing MariaDB Connector/J via JAR

To download the JAR file manually:

  1. Go to the MariaDB Connectors download page

  2. Within the "Product" drop-down, choose the "Java 8 connector" or "Java 7 connector".

  3. Click the "Download" button to download the JAR file.

  4. When the JAR file finishes downloading, place it into the relevant directory on your system.

  5. Confirm that the JAR file is in your Java CLASSPATH.

Connecting with MariaDB Connector/J

  1. Determine the connection information for your MariaDB SkySQL database service:


    Where to find it


    Default username in the Service Credentials view, or the username you created


    Default password in the Service Credentials view, the password you set on the default user, or the password for the user you created


    Path to the skysql_chain.pem file containing the "Certificate Authority Chain" (Download)


    Set to the string "true" to enable TLS, which is required for SkySQL.

    getConnection URL
    host component

    Fully Qualified Domain Name in the Service Details view

    getConnection URL
    port component

    Read-Write Port or Read-Only Port in the Service Details view

    • Connection parameters can be set either in the Properties object or in the connection URL.

  2. In your Java code, connect to the database service by calling the DriverManager.getConnection(String url, Properties info) method. Connection parameters can be set either in the Properties object or in the connection URL.

    import java.sql.*;
    import java.util.Properties;
    public class MariaDB_Connection_Test {
       public static void main(String[] args) {
          Properties connProperties = new Properties();
          connProperties.setProperty("user", "db_user");
          connProperties.setProperty("password", "db_password");
          connProperties.setProperty("useSsl", "true");
          connProperties.setProperty("serverSslCert", "/path/to/skysql_chain.pem");
          try (Connection conn = DriverManager.getConnection(
                connProperties)) {
             // Use the connection
             // ...
          } catch (Exception e) {
  3. Make sure that your Java CLASSPATH includes the path to your new Java code as well as the path to MariaDB Connector/J.

    For example, you can set the Java CLASSPATH on Linux by executing the following:

    $ export CLASSPATH='/path/to/application/:/path/to/mariadb-java-client-2.7.2.jar'
  4. Compile your Java code:

    $ javac
  5. Execute your Java class:

    $ java MariaDB_Connection_Test