Application Development with MariaDB Connector/J


Using projects with MariaDB Connector/J vary depending on the installation method you use.

Build with the JAR File

When developing your Java application without Maven, the process is more manual:

  1. Add your application and the JAR for MariaDB Connector/J to the Java CLASSPATH:

    $ export CLASSPATH="/path/to/application:/path/to/mariadb-java-client-3.3.3.jar"
  2. Compile your application:

    $ javac
  3. Execute the Java class:

    $ java App

Build with a Java IDE

If using a Java IDE, create a Maven project and add the dependencies to pom.xml.

For additional information, see "Install MariaDB Connector/J via Maven".

Build with Maven

When using command-line Maven to manage your Java builds, running build downloads and installs the relevant JAR dependencies and compiles your project:

  1. Build the package:

    $ mvn package
  2. Run the application:

    $ java -jar target/app.jar

Java Classes

Connections are created, used, and managed using the following Java classes:




Represents a connection with a specific database.


Manages JDBC Drivers including establishing a connection to a database.

Statements are executed using the following Java classes:




Use a prepared SQL statement when the query needs to execute multiple times in succession or when it requires text from the user to specify the fields to protect against SQL injections.


Create an SQL statement when you need to execute a single self-contained query that does not require text from the user.