Last Updated on 28 October 2023   |   Print Email
While developing Java applications with Spring Boot and JDBC, you may get confused when you see there are two variants of MySQL JDBC driver: mysql-connector-javaand mysql-connector-j. If Maven is used, the dependency declaration for the first one is:
What’s the difference? Which one is correct? Which one should be used?Well, the first one, mysql-connector-java was the original MySQL JDBC driver, but it doesn’t follow reverse-DNS convention of Maven with group Id is something like com.companynameand artifact Id is product/library name.So recently, the MySQL JDBC driver library was changed to adopt Maven’s naming convention, with group Id is com.mysql and artifact Id is mysql-connector-j because the official name of MySQL JDBC driver is MySQL Connector/J. Hence the following dependency should be used:
You know, Spring Boot defines default versions for common dependencies, including MySQL JDBC driver. That means if you upgrade your Spring Boot application to version 3.1 or newer, the following declaration won’t work:
If you use MySQL JDBC driver in non-Spring Boot application, you must specify dependency version so you can use either one. Both will work.I hope this post has cleared your doubts about the differences between mysql-connector-javaand mysql-connector-j, and now know which one should be used. You can also watch the video below:
Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.
Comments