Issue
Recently I was working with JDBC, and all code which uses JDBC were working perfectly.
After some time I started using JDBC again to refresh all concepts. The problem is, when I wrote my new program at that time, it gave me ClassNotFoundException. Everything in my code was perfect. I also added the external JAR file of the MySQL connector. The exception was ClassNotFoundException com.mysql.jdbc.Driver.
I tried different IDEs to run that code, but it gave me the same error. But then I tried to import this MySQL connector from the Maven repository and all the exceptions were cleared and executed perfectly.
Previously I was using this MySQL connector. Also both connectors versions were the same which was 8.0.11. I have really less amount of knowledge of Maven.
Why did the MySQL connector JAR file from Maven work perfectly and the other didn't?
Solution
Based on what you've said, it sounds like your manually-imported JAR file didn't import for one reason or another. The Maven import was successful and everything clicked.
The other thing that's possible is that you're using a different version of the MySQL JDBC driver.
Answered By - JWilliams
Answer Checked By - Mary Flores (JavaFixing Volunteer)