I am writing a simple Flink program to move data from MySQL to Mongo.
I'm using mysql-connector-java 8.0.16.
When I try to connect to our test env DB (MySQL 8.0.15) the program works just fine. The connection string looks like this:
jdbc:mysql://my-test-db-url:3306/my_db_name
But once I connect it to our production DB (MySQL 8.0.16), I got:
java.sql.SQLException: No suitable driver found for jdbc:mysql://my-prod-db-url:3306/my_db_name
The only difference of these DBs is the minor version (15 vs 16).
I upgraded my test DB to 8.0.16 to see if it's a problem with that version of mysql server. And indeed now I can't connect to test DB, too, getting the same exception.
After that I continued to upgrade both mysql-connector-java and test DB to 8.0.17, but the problem still persists.
In my other projects I can connect to those mysql DBs just fine (using spring data jpa with mysql-connector-java 8.0.18). So the db server shouldn't have any problem.
This didn't work
no error was thrown in main class
// tried both
Class.forName("com.mysql.jdbc.Driver").newInstance();
Class.forName("com.mysql.cj.jdbc.Driver").newInstance();
I also made sure after running maven package, my fat jar does contain the connector class files.
Now I'm pretty much clueless. Somebody please save me.
I resolved same issue using Class.forName("org.sqlite.JDBC") (I were using sqlite) before calling DriverManager.getConnection. It's almost same that you've tried but without calling newInstance().