Как подключить библиотеку JDBC(обычную)

32
4
Код сам я написал, подключил библиотеку вот так:

screenshot_234-png.13015



Пишет ошибку что библиотеки нету.

Код:
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at java.sql.DriverManager.getConnection(DriverManager.java:689)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at java.sql.DriverManager.getConnection(DriverManager.java:247)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at toperclient.com.io.gui.login.MysqlKeys.getKey(MysqlKeys.java:21)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at toperclient.com.io.gui.login.GuiLoginMysql.mouseClicked(GuiLoginMysql.java:110)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:533)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:501)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at net.minecraft.client.Minecraft.runTick(Minecraft.java:1759)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1098)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at net.minecraft.client.Minecraft.run(Minecraft.java:398)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at net.minecraft.client.main.Main.main(Main.java:118)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at java.lang.reflect.Method.invoke(Method.java:498)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at java.lang.reflect.Method.invoke(Method.java:498)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at net.minecraftforge.legacydev.Main.start(Main.java:86)
[16:15:20] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:29]:     at net.minecraftforge.legacydev.MainClient.main(MainClient.java:29)

Что делать?
 

Вложения

  • Screenshot_234.png
    Screenshot_234.png
    975 байт · Просмотры: 84
32
4
Screenshot_235.png
Screenshot_236.png

Код:
Build file 'C:\Users\ИмяЗамажу\Downloads\GrozaClient Fixxed\build.gradle' line: 8

A problem occurred evaluating root project 'GrozaClient Fixxed'.
> Could not find method compile() for arguments [{group=mysql, name=mysql-connector-java, version=8.0.26}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
 
1,074
72
372
В более новых версиях gradle вместо слова compile используется implementation
А зачем собственно на клиенте нужен MySQL? Максимум подхходит встраиваемый SQLite.
 
1,074
72
372
Всё очень плохо тогда. Базу хакнут, если данные подключения будут у клиента.
Должно использоваться API, с которым общается клиент. Оно как раз будет фильтровать входящие запросы.
 
32
4
У меня ещё вопрос. Я слишком туп в mysql.
Screenshot_237.png

Java:
private static String bd = "licenses";

private static String user = "root";

private static String pass = "";

private static String url = "jdbc:mysql://IpАдрес:3306/"+bd;



private static Connection c;

private static Statement st;

private static ResultSet result;



public static void getKey(String name, String key) {

    String q = "select * from "+bd;



    try {

        c = DriverManager.getConnection(url, user, pass);

        st = c.createStatement();

        result = st.executeQuery(q);



        System.out.println("=========================================");

        System.out.println(result.getString(1));

        System.out.println("=========================================");

    } catch(SQLException ex) {

        ex.printStackTrace();

    } finally {

        try { c.close(); } catch (SQLException ex) {}

        try { st.close(); } catch (SQLException ex) {}

        try { result.close(); } catch (SQLException ex) {}

    }

}

Код:
[17:06:47] [Client thread/INFO] [STDOUT]: [toperclient.com.io.gui.login.MysqlKeys:getKey:25]: =========================================
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]: java.sql.SQLException: Illegal operation on empty result set.
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at com.mysql.cj.jdbc.result.ResultSetImpl.checkRowPos(ResultSetImpl.java:517)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at com.mysql.cj.jdbc.result.ResultSetImpl.getString(ResultSetImpl.java:870)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at toperclient.com.io.gui.login.MysqlKeys.getKey(MysqlKeys.java:26)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at toperclient.com.io.gui.login.GuiLoginMysql.mouseClicked(GuiLoginMysql.java:128)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:533)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:501)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraft.client.Minecraft.runTick(Minecraft.java:1759)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1098)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraft.client.Minecraft.run(Minecraft.java:398)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraft.client.main.Main.main(Main.java:118)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at java.lang.reflect.Method.invoke(Method.java:498)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at java.lang.reflect.Method.invoke(Method.java:498)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraftforge.legacydev.Main.start(Main.java:86)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraftforge.legacydev.MainClient.main(MainClient.java:29)

Что не так?
 
32
4
У меня ещё вопрос. Я слишком туп в mysql.
Посмотреть вложение 13019

Java:
private static String bd = "licenses";

private static String user = "root";

private static String pass = "";

private static String url = "jdbc:mysql://IpАдрес:3306/"+bd;



private static Connection c;

private static Statement st;

private static ResultSet result;



public static void getKey(String name, String key) {

    String q = "select * from "+bd;



    try {

        c = DriverManager.getConnection(url, user, pass);

        st = c.createStatement();

        result = st.executeQuery(q);



        System.out.println("=========================================");

        System.out.println(result.getString(1));

        System.out.println("=========================================");

    } catch(SQLException ex) {

        ex.printStackTrace();

    } finally {

        try { c.close(); } catch (SQLException ex) {}

        try { st.close(); } catch (SQLException ex) {}

        try { result.close(); } catch (SQLException ex) {}

    }

}

Код:
[17:06:47] [Client thread/INFO] [STDOUT]: [toperclient.com.io.gui.login.MysqlKeys:getKey:25]: =========================================
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]: java.sql.SQLException: Illegal operation on empty result set.
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at com.mysql.cj.jdbc.result.ResultSetImpl.checkRowPos(ResultSetImpl.java:517)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at com.mysql.cj.jdbc.result.ResultSetImpl.getString(ResultSetImpl.java:870)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at toperclient.com.io.gui.login.MysqlKeys.getKey(MysqlKeys.java:26)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at toperclient.com.io.gui.login.GuiLoginMysql.mouseClicked(GuiLoginMysql.java:128)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:533)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:501)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraft.client.Minecraft.runTick(Minecraft.java:1759)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1098)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraft.client.Minecraft.run(Minecraft.java:398)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraft.client.main.Main.main(Main.java:118)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at java.lang.reflect.Method.invoke(Method.java:498)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at java.lang.reflect.Method.invoke(Method.java:498)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraftforge.legacydev.Main.start(Main.java:86)
[17:06:47] [Client thread/INFO] [STDERR]: [toperclient.com.io.gui.login.MysqlKeys:getKey:30]:     at net.minecraftforge.legacydev.MainClient.main(MainClient.java:29)

Что не так?
Разобрался :)
 
1,074
72
372
Java:
} finally {
        try { c.close(); } catch (SQLException ex) {}
        try { st.close(); } catch (SQLException ex) {}
        try { result.close(); } catch (SQLException ex) {}
    }
Ужас так писать. Во времена Java 6 это было актуально.
 
Сверху