MYSQL Connector Driver Issue

Hi, I'm trying to implement an sql database, but I'm only getting the "No suitable driver found", anyone knows why it could be? implementation group: 'com.mysql', name: 'mysql-connector-j', version: '9.1.0' Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/name?user=user&password=password
37 Replies
JavaBot
JavaBotā€¢3w ago
āŒ› This post has been reserved for your question.
Hey @ponchisao326! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Yuvi
Yuviā€¢3w ago
Hey @ponchisao326 Use Class.forName("com.mysql.cj.jdbc.Driver"); to load driver.
JavaBot
JavaBotā€¢3w ago
šŸ’¤ Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
ponchisao326
ponchisao326OPā€¢3w ago
that's no longer necesary in modern sql connector versions, however I already tryed it with no result
JavaBot
JavaBotā€¢3w ago
šŸ’¤ Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
dan1st
dan1stā€¢3w ago
no result meaning same exception or different exception?
ponchisao326
ponchisao326OPā€¢3w ago
same exception šŸ«  I mean, it just says "no suitable driver found for com. mysql.cj.jdbc.Driver"
dan1st
dan1stā€¢3w ago
wait, is it really that exact text? not something like no suitable driver found for jdbc:mysql:...? How are you running the project?
ponchisao326
ponchisao326OPā€¢3w ago
with the class.forName is what I said on Intellij with Gradle
dan1st
dan1stā€¢3w ago
Did it really not say ClassNotFoundException? Can you show the full stack trace?
ponchisao326
ponchisao326OPā€¢3w ago
let me check again Okay, let me code it again and I will show you
ponchisao326
ponchisao326OPā€¢3w ago
this is with the class.forName
ponchisao326
ponchisao326OPā€¢3w ago
This without the class.forName
dan1st
dan1stā€¢3w ago
oh this is a Minecraft thing make sure the JDBC driver is available at runtime like when the mod or whatever it is is loaded, make sure the JDBC driver is loaded with it
ponchisao326
ponchisao326OPā€¢3w ago
how can I make that?
dan1st
dan1stā€¢3w ago
idk how Minecraft does it
ponchisao326
ponchisao326OPā€¢3w ago
haha
dan1st
dan1stā€¢3w ago
maybe you need to add the JAR to the directory maybe it has a specific Gradle thing you have to mark the dependency with (i.e. maybe implementation may be the wrong option)
ponchisao326
ponchisao326OPā€¢3w ago
I tryed with runtimeOnly & compileOnly aswell as with implementation
dan1st
dan1stā€¢3w ago
like maybe there's a directory where you should put libs in maybe you have a config file where you also have to specify necesssary dependencies
ponchisao326
ponchisao326OPā€¢3w ago
I think that's not possible in minecraft modding šŸ« 
dan1st
dan1stā€¢3w ago
idk how Minecraft modding works
ponchisao326
ponchisao326OPā€¢3w ago
I know your point and its a good option, but I don't think there's a way to do that on minecraft modding
dan1st
dan1stā€¢3w ago
though actually there is something you could maybe do
ponchisao326
ponchisao326OPā€¢3w ago
My last option is to use an sqlite file and send it to the server via sftp or smth but I don't even know if it would be a good option though
dan1st
dan1stā€¢3w ago
Can you run Class.forName("com.mysql.cj.jdbc.Driver", true, getClass().getClassLoader());?
ponchisao326
ponchisao326OPā€¢3w ago
yeah, on my way Caused by: java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver
dan1st
dan1stā€¢3w ago
Did you still have the old Class.forName in it?
ponchisao326
ponchisao326OPā€¢3w ago
nope, I've replaced it
JavaBot
JavaBotā€¢3w ago
šŸ’¤ Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
ponchisao326
ponchisao326OPā€¢3w ago
Okay, I've tryed in another project with maven and it's working, I don't know why I have the same thing on the two projects but it's not working šŸ« 
dan1st
dan1stā€¢3w ago
I think it's probably because of how Minecraft loads stuff
ponchisao326
ponchisao326OPā€¢3w ago
yeah, I think so or maybe a gradle problem but I don't know Okay, definitely is a minecraft forge problem
dan1st
dan1stā€¢3w ago
You could try printing JdbcConnection.class and check what happens with that
ponchisao326
ponchisao326OPā€¢3w ago
gonna try
JavaBot
JavaBotā€¢2w ago
šŸ’¤ Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server