JDBC Driver Maven dependency list

Imagine having a tool that can automatically detect if you are using JPA and Hibernate properly. Hypersistence Optimizer is that tool!

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 JDK 10 and 11, use the following Maven dependency:

<dependency>
    <groupId>com.oracle.ojdbc</groupId>
    <artifactId>ojdbc10</artifactId>
    <version>${oracle.version}</version>
</dependency>

For JDK 8, use the ojdbc8 artifact instead:

<dependency>
    <groupId>com.oracle.ojdbc</groupId>
    <artifactId>ojdbc8</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, you need to install the SAP HANA Client and import the JDBC Driver into your local Maven repository.

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.

FREE EBOOK

2 Comments on “JDBC Driver Maven dependency list

  1. Is there a maven dependency for tandem jdbc driver, something like t4sqlmx.jar?

    • Probably. I haven’t ever used it, so I’m not sure what JDBC driver it’s needed for Tandem.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.