Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello,

I'm trying to connect my mod to a mysql database and I get an SQLException.

Here are the dependencies and repos of my build.gradle

repositories {
    // Put repositories for dependencies here
    // ForgeGradle automatically adds the Forge maven and Maven Central for you

    // If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
    // flatDir {
    //     dir 'libs'
    // }
}

dependencies {
    minecraft 'net.minecraftforge:forge:1.17.1-37.0.58'
    implementation 'mysql:mysql-connector-java:8.0.26'
}

 

  • Author

Here it is:

java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/spell?autoReconnect=true&useSSL=false
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:702)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)
	at TRANSFORMER/[email protected]/fr.steakmans.spellmod.mysql.Mysql.connect(Mysql.java:14)
	at TRANSFORMER/[email protected]/fr.steakmans.spellmod.Main.serverStarting(Main.java:51)
	at MC-BOOTSTRAP/[email protected]/net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:247)
	at MC-BOOTSTRAP/[email protected]/net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:239)
	at MC-BOOTSTRAP/[email protected]/net.minecraftforge.eventbus.EventBus.post(EventBus.java:302)
	at MC-BOOTSTRAP/[email protected]/net.minecraftforge.eventbus.EventBus.post(EventBus.java:283)
	at TRANSFORMER/[email protected]/net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleServerStarting(ServerLifecycleHooks.java:101)
	at TRANSFORMER/[email protected]/net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:211)
	at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:659)
	at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:258)

 

  • Author

So here is the method were i'm trying to connect:

    public void serverStarting(FMLServerStartingEvent e) {
        mysql.connect("localhost", 3306, "db", "user", "mdp");
    }

And here is the class with all the functions

private Connection conn;

    public void connect(String host, int port, String database, String user, String password) {
        if(!isConnected()){
            try {
                conn = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, user, password);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

    public void disconnect(){
        if(isConnected()){
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

    public boolean isConnected(){
        try {
            if((conn == null) || (conn.isClosed()) || conn.isValid(5)){
                return false;
            }
            return true;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return false;
    }


    public Connection getConnection() {
        return conn;
    }

I'm dumb I forgot to shade the mysql driver

Edited by steakmans
Found the solution

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.