Application Development with MariaDB Connector/J
This page is part of MariaDB's Documentation.
The parent of this page is: MariaDB Connector/J
Topics on this page:
Overview
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
CLASSPATH
:$ export CLASSPATH="/path/to/application:/path/to/mariadb-java-client-3.3.3.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 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:
Build the package:
$ mvn package
Run the application:
$ java -jar target/app.jar
Java Classes
Connections are created, used, and managed using the following Java classes:
Class | Description |
---|---|
| 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:
Class | Description |
---|---|
| 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. |