Jump to content

MySQL connector/J is not working


aut1sto

Recommended Posts

Minecraft version: 1.18.2

Forge version: 40.1.29

I want to connect to database with my minecraft mod, in the Internet I found solution to add lib MySQL connector/J and Class.forName("com.mysql.cj.jdbc.Driver"); line, but i get java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver. How can i import MySQL connector/J into my mod?

 

Link to comment
Share on other sites

  • 1 year later...

Working example

plugins {
   //......
}


version = '1.0'
group = 'com.bodryak.gmod' 
archivesBaseName = 'gmodmod'


jarJar.enable()

tasks.jarJar.configure { }

minecraft {.....}

dependencies {
    minecraft 'net.minecraftforge:forge:1.19.2-43.2.3'
    implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.33'
    jarJar(group: 'mysql', name: 'mysql-connector-java', version: '[8.0.26,8.0.33)'){
        jarJar.pin(it, "8.0.33")
    }
}

inser :

 

jarJar.enable()

tasks.jarJar.configure { }

before minecraf{ }

and

    implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.33'
    jarJar(group: 'mysql', name: 'mysql-connector-java', version: '[8.0.26,8.0.33)'){
        jarJar.pin(it, "8.0.33")
    }

in dependencies

and after compilation the connector will be embroidered into the jar

 

in order for the connector to work in the test environment during runtime, you need

edit file runClient_minecraftClasspath

insert full path to mysql connector in the first line

after that mysql connector will run with the client

if that doesn't work, you'll need to deep tune the programming environment, but the point remains the same: you'll need to configure the launch options for the client along with the MSCL library

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.