MySQL JDBC driver not found using mysql driver dependency

  • After careful consideration and due to limited usage, we’ve made the decision to discontinue the PaperMC forums. Moving forward, we recommend using Hangar for plugin uploads, and for all other community discussions and support, please join us on Discord.

Thice

New member
Feb 8, 2024
2
0
1
Dear

I was working on a plugin, that connects to the MySQL database.
When connecting to MySQL the way I did in paper would not work and results in the error: No suitable driver found for <database_url>
I've fixed this by adding: Class.forName("com.mysql.cj.jdbc.Driver");
And adding the MySQL connector dependency. Now I still got the error.
I've also tried to add it via the jar, in the modules, also resulting in the same error.

Java version: 20

See images.

Thank you for the help! :D
 

Attachments

  • maven.png
    maven.png
    124.7 KB · Views: 15
  • error.png
    error.png
    98.5 KB · Views: 13
  • mysql.png
    mysql.png
    32.7 KB · Views: 14
  • pom.png
    pom.png
    28.7 KB · Views: 14

Digital'Inc

New member
Feb 10, 2024
2
0
1
The maven-shade-plugin didn't work for me. What helped me was adding (-cp "path\to\mariadb-java-client-3.3.0.jar") to the startup .bat file. But I would like to do without it. Could you show a minimal working plugin using mysql built through maven?
 

_1ms

New member
Jun 30, 2024
3
0
1
Thanks, I've found a solution.
I'm having the same issue now, I shade the com.mysql:mysql-connector-j:9.0.0 in the jar with gradle, but it still gives the same java.sql.SQLException: No suitable driver found for jdbc:mysql://127.0.0.1:3306/mydb error as yours. Do you think you can say how you've solved it?