Application Development with MariaDB Connector/J
This page is part of MariaDB's MariaDB Documentation.
The parent of this page is: MariaDB Connector/J
Topics on this page:
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:
Add your application and the JAR for MariaDB Connector/J to the Java
$ export CLASSPATH="/path/to/application:/path/to/mariadb-java-client-3.0.10.jar"
Compile your application:
$ javac App.java
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
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:
Build the package:
$ mvn package
Run the application:
$ java -jar target/app.jar
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.