JDBC Driver Maven dependency list
Imagine having a tool that can automatically detect JPA and Hibernate performance issues. Wouldn’t that be just awesome?
Well, Hypersistence Optimizer is that tool! And it works with Spring Boot, Spring Framework, Jakarta EE, Java EE, Quarkus, or Play Framework.
So, enjoy spending your time on the things you love rather than fixing performance issues in your production system on a Saturday night!
Introduction
Ever wanted to connect to a relational database using Java and didn’t know which JDBC Driver Maven dependency to use?
If so, this article is surely going to help you from now on.
Oracle
Since September 2019, the Oracle JDBC Driver is available on Maven Central.
For Java 11 and newer version, use the following Maven dependency:
<dependency> <groupId>com.oracle.database.jdbc</groupId> <artifactId>ojdbc10</artifactId> <version>${oracle.version}</version> </dependency>
For Java 8, use the ojdbc8
artifact instead:
<dependency> <groupId>com.oracle.database.jdbc</groupId> <artifactId>ojdbc8</artifactId> <version>${oracle.version}</version> </dependency>
For Java 6, use the ojdbc6
artifact instead:
<dependency> <groupId>com.oracle.database.jdbc</groupId> <artifactId>ojdbc6</artifactId> <version>${oracle.version}</version> </dependency>
For more details about the proper version to use, check out the following Maven Central link.
MySQL
The MySQL Driver is available on Maven Central, so just add the following dependency to your pom.xml file:
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.version}</version> </dependency>
Use this Maven Central link to get the latest artifact version for the MySQL JDBC Driver.
PostgreSQL
The PostgreSQL Driver is available on Maven Central, so us the following dependency:
<dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>${postgresql.version}</version> </dependency>
This Maven Central link will tell you which is the latest version of the PostgreSQL JDBC artifact.
SQL Server
While many years ago, the official Microsoft SQL Server JDBC Driver was in a bad shape, to the extent that the Java community created the jTDS open-source JDBC Driver, nowadays, the SQL Server JDBC Driver is open-source and available on both GitHub and Maven Central:
<dependency> <groupId>com.microsoft.sqlserver</groupId> <artifactId>mssql-jdbc</artifactId> <version>${mssql.version}</version> </dependency>
To get the latest version of the SQL Server JDBC Driver, use this Maven Central query link.
Db2
You can get the Db2 JDBC Driver either from the IBM website and install it to your local Maven repository, or get it from Maven Central.
<dependency> <groupId>com.ibm.db2</groupId> <artifactId>jcc</artifactId> <version>${db2.version}</version> </dependency>
To get the latest version of the Db2 JDBC Driver, use this Maven Central query link.
MariaDB
You can get the MariaDB JDBC Driver from Maven Central using the following dependency:
<dependency> <groupId>org.mariadb.jdbc</groupId> <artifactId>mariadb-java-client</artifactId> <version>${mariadb.version}</version> </dependency>
Use this Maven Central link to get the latest artifact version for the MariaDB JDBC Driver.
SAP Hana
To get the SAP HANA JDBC Driver from Maven central using the following dependency.
Afterward, use the following Maven dependency:
<dependency> <groupId>com.sap.cloud.db.jdbc</groupId> <artifactId>ngdbc</artifactId> <version>${hana.version}</version> </dependency>
Informix
Since 2017, the Informix JDBC Driver is available on Maven Central. Use the following Maven dependency to get it:
<dependency> <groupId>com.ibm.informix</groupId> <artifactId>jdbc</artifactId> <version>${informix.version}</version> </dependency>
This Maven Central query link will provide you the latest version of the Informix JDBC Driver.
Firebird
Jaybird is the JDBC Driver for Firebird, and you can get it from Maven Central like this:
<dependency> <groupId>org.firebirdsql.jdbc</groupId> <artifactId>jaybird</artifactId> <version>${jaybird.version}</version> </dependency>
To get the latest version of the Firebird JDBC Driver, use this Maven Central query link.
HSQLDB
You can get the HyperSQL JDBC Driver using the following Maven dependency:
<dependency> <groupId>org.hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>${hsqldb.version}</version> <scope>test</scope> </dependency>
Use this Maven Central link to get the latest artifact version for the HSQLDB JDBC Driver.
H2
The H2 database JDBC Driver is available on Maven Central, so you can use the following Maven dependency:
<dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>${h2.version}</version> <scope>test</scope> </dependency>
This Maven Central link will tell you which is the latest version of the H2 JDBC artifact.
Derby
Use the following Maven dependency to get the Apache Derby JDBC Driver from Maven Central:
<dependency> <groupId>org.apache.derby</groupId> <artifactId>derby</artifactId> <version>${derby.version}</version> <scope>test</scope> </dependency>
To get the latest version of the Derby JDBC Driver, use this Maven Central query link.
That’s it!
If you enjoyed this article, I bet you are going to love my Book and Video Courses as well.
Conclusion
Knowing the JDBC Driver Maven dependency is mandatory if you want to connect to a relational database system from a Java application.
If there is a database system that I forgot to add, add a comment, and I’ll update the article.
