#MYSQL Connector Driver Issue

59 messages · Page 1 of 1 (latest)

vital karma
#

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

spice magnetBOT
#

This post has been reserved for your question.

Hey @vital karma! 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.

ember nimbus
#

Hey @vital karma
Use Class.forName("com.mysql.cj.jdbc.Driver"); to load driver.

spice magnetBOT
#

💤 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.

vital karma
spice magnetBOT
#

💤 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.

marble hearth
vital karma
#

I mean, it just says "no suitable driver found for com. mysql.cj.jdbc.Driver"

marble hearth
#

not something like no suitable driver found for jdbc:mysql:...?

#

How are you running the project?

vital karma
vital karma
marble hearth
#

Can you show the full stack trace?

vital karma
vital karma
vital karma
marble hearth
#

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

vital karma
#

how can I make that?

marble hearth
#

idk how Minecraft does it

vital karma
marble hearth
#

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)

vital karma
#

aswell as with implementation

marble hearth
#

maybe you have a config file where you also have to specify necesssary dependencies

vital karma
#

🫠

marble hearth
#

idk how Minecraft modding works

vital karma
#

I know your point and its a good option, but I don't think there's a way to do that on minecraft modding

marble hearth
#

though actually there is something you could maybe do

vital karma
#

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

marble hearth
#

Can you run Class.forName("com.mysql.cj.jdbc.Driver", true, getClass().getClassLoader());?

vital karma
#

yeah, on my way

vital karma
marble hearth
vital karma
spice magnetBOT
#

💤 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.

vital karma
#

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

#

🫠

marble hearth
#

I think it's probably because of how Minecraft loads stuff

vital karma
#

yeah, I think so

#

or maybe a gradle problem

#

but I don't know

#

Okay, definitely is a minecraft forge problem

marble hearth
#

You could try printing JdbcConnection.class and check what happens with that

vital karma
#

gonna try