javamavenmysql-connector

mysql-connector-j vs mysql-connector-java maven dependency differences


What is difference between these two Maven dependencies for connecting to MySQL DB:

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
</dependency>

and

<dependency>
    <groupId>com.mysql</groupId>
    <artifactId>mysql-connector-j</artifactId>
</dependency>

Solution

  • TL;DR

    Use this

    <dependency>
        <groupId>com.mysql</groupId>
        <artifactId>mysql-connector-j</artifactId>
    </dependency>
    

    MySQL renamed the connector:

    You should use MySQL Connector/J.


    If you are using the Spring-Boot-3.0 or above then you should use MySQL Connector/J.

    The coordinates of the MySQL JDBC driver have changed from mysql:mysql-connector-java to com.mysql:mysql-connector-j. If you are using the MySQL JDBC driver, update its coordinates accordingly when upgrading to Spring Boot 3.0.

    Source


    Also from the comment @Mar-Z provided this information:

    The second one is the correct/current one. The first one is outdated. It will be updated on Maven but for a limited time only. Check here: MySQL Connector/J has new Maven Coordinates