Reputation: 807
My Exception:
java.sql.SQLException: No suitable driver found for jdbc:mysql://SOME_ID_HERE.SOME_NUMBERS_HERE.eu-west-1.rds.amazonaws.com:3306/DB_NAME?verifyServerCertificate=true&useSSL=true&requireSSL=true
My project is using Maven, so I have previously had success by just adding libraries to my POM.xml file, and it would work both in eclipse as well as on the server that runs my web app/site.
My POM.xml file:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
</dependency>
This is where get the connection:
DriverManager.getConnection("jdbc:mysql://SOME_ID_HERE.SOME_NUMBERS_HERE.eu-west-1.rds.amazonaws.com:3306/DB_NAME_TWO?verifyServerCertificate=true&useSSL=true&requireSSL=true", userName, password);
On my own PC running eclipse, everything works fine, just adding the library in the POM makes it work. What do I need to do to make it work on the server?
I tried adding Class.forName("com.mysql.jdbc.Driver");
before getting the connection, but this caused it to basically just crash without giving me any errors.
I've also tried downloading mysql-connector-java-5.1.39-bin.jar
, but I am unsure where to put it. The server was custom built by someone else before I was hired, and doesn't necessarily have a lib folder, or I don't know where/what it is.
I've also tried adding -cp mysql-connector-java-5.1.18-bin.jar:.
or -cp mysql-connector-java-5.1.18-bin.jar
to the execution of my java -jar /program.jar
. Which did not seem to make any difference.
I may be using some kind of pooling, if that is relevant (heard some mentions in comments, while searching for a solution, that it may be).
java.util.concurrent.Executors.newCachedThreadPool();
How do I get jdbc:mysql driver to work on my server? Please be very specific when coming with suggestions, thank you very much for your time.
Upvotes: 1
Views: 5038
Reputation: 807
One of the things I mentioned in the bottom of the post apparently did work. Downloading the jar file for mysql-connector-java did work (possibly also requires to add it to classport with the export command). When I changed the version in Maven to match the one I had downloaded, I can now connect. The difference between the two was obviously a mistake.
Upvotes: 1