- 1
- 0
Java:
import javax.swing.*;
import java.sql.*;
public class MysqlKeys {
private static String bd = "licenses";
private static String user = "root1";
private static String pass = "ПарольНеСкажу";
private static String url = "jdbc:mysql://164.90.217.151/admin228/licenses?useUnicode=yes&characterEncoding=UTF-8&useSSL=false";
private static Connection c;
private static Statement st;
private static ResultSet result;
public static boolean getKey(String name, String key) {
boolean b = false;
String q = "select "+name+" from "+bd;
try {
c = DriverManager.getConnection(url, user, pass);
st = c.createStatement();
result = st.executeQuery(q);
while(result.next()) {
String trueKey = result.getString(1);
if(trueKey.equals(key)) {
b = true;
}
}
} catch(SQLException ex) {
ex.printStackTrace();
return false;
} finally {
try { c.close(); } catch (SQLException ex) {}
try { st.close(); } catch (SQLException ex) {}
try { result.close(); } catch (SQLException ex) {}
}
return b;
}
}
[21:01:12] [Client thread/INFO]: [STDERR]: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
[21:01:12] [Client thread/INFO]: [STDERR]: at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
[21:01:12] [Client thread/INFO]: [STDERR]: at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
[21:01:12] [Client thread/INFO]: [STDERR]: at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
[21:01:12] [Client thread/INFO]: [STDERR]: at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
[21:01:12] [Client thread/INFO]: [STDERR]: at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
[21:01:12] [Client thread/INFO]: [STDERR]: at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
[21:01:12] [Client thread/INFO]: [STDERR]: at java.sql.DriverManager.getConnection(Unknown Source)
[21:01:12] [Client thread/INFO]: [STDERR]: at java.sql.DriverManager.getConnection(Unknown Source)
[21:01:12] [Client thread/INFO]: [STDERR]: at me.rich.auth.MysqlKeys.getKey(MysqlKeys.java:22)
[21:01:12] [Client thread/INFO]: [STDERR]: at me.rich.auth.GuiLoginMysql.mouseClicked(GuiLoginMysql.java:109)
[21:01:12] [Client thread/INFO]: [STDERR]: at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:581)
[21:01:12] [Client thread/INFO]: [STDERR]: at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:550)
[21:01:12] [Client thread/INFO]: [STDERR]: at net.minecraft.client.Minecraft.runTick(Minecraft.java:1885)
[21:01:12] [Client thread/INFO]: [STDERR]: at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1200)
[21:01:12] [Client thread/INFO]: [STDERR]: at net.minecraft.client.Minecraft.run(Minecraft.java:483)
[21:01:12] [Client thread/INFO]: [STDERR]: at net.minecraft.client.main.Main.main(Main.java:115)
[21:01:12] [Client thread/INFO]: [STDERR]: at Start.main(Start.java:11)
[21:01:12] [Client thread/INFO]: [STDERR]: Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
что не так?