No suitable driver found for jdbc:mysql://localhost - Connector/J 8.0.32

Good day,

What I have in mind: I have rented a server (Ubuntu 22.04) and installed a mysql server there (8.0.32-0ubuntu0.22.04.2). I now wanted to run a jar file on the server (Java: OpenJDK Runtime Environment build 18.0.2-ea+9-Ubuntu-222.04) which automatically writes data to my database.

Problem: When I ran the mysql server on the home computer with the jar program on the PC it worked without any problems. When I accessed the Mysql server on the server from my home computer, I was also able to write data automatically. When I now tried to execute the jar file on the server in order to access the Mysql server on the server, I always received the error message: "No suitable driver found for jdbc:mysql://localhost".

What I have done so far: -I enabled port 3306 in the firewall. -I tried to specify the IP address of my server instead of jdbc:mysql://localhost (jdbc:mysql://XXXXXXX). -I have inserted the jar file for the Connector/J 8.0.32 (Platform Independent) into my IntelliJ project. -My user for the mysql server has admin rights and the password is also correct.

Now I don't know what to do. From my PC, I can use the jar file to automatically write data to the mysql server on the server, so the connector/j should work, but it doesn't work with the jar file on the server.

Upvotes: 1

Views: 944

Answers (1)

Nahuel Giani
Nahuel Giani

Reputation: 570

If you doesnt have the connector/J library into your jar file, just add this dependency in your pom.xml:

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.28</version>
</dependency>

Upvotes: 0

Related Questions