0

I'm trying to connect to a simple MySQL server through the JDBC driver. The driver version is 8.0.30 which I believe is the most recent and the Java version I'm using is Corretto 16 (IntelliJ's thing) with Gradle 7.1.

When I run the code through the IDE, I can connect to the database just fine and my program works as it should. But, when I export it to a JAR and try and run it, I get an SQLException error, complaining that there is 'no suitable driver found' to run the JDBC string in the DriverManager#getConnection call. If it makes any difference whatsoever the code itself whilst being compiled in Corretto 16 is being run in OpenJDK 19 in Windows' command prompt.

I've tried everything I can find, everything I have done has not fixed it. The JAR for JDBC is in my exported JAR (I have checked) and I'm out of ideas. I'm sorry if this is an amateur issue, whilst I've been writing Java for a few years now I've never had to deal with JDBC.

P.S. I'm aware of the questions that are similar to this one, however many of them are highly outdated or are using software that I do not use, hence a new question. Sorry if there's one I missed.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
skaerf
  • 1
  • 1

0 Answers0