我最近开始开发minecraft插件,但是即使我始终使用游戏的1.8版进行开发,连接到mysql的方法也已更改。我更新了插件中的依赖项,但始终给我错误...有人可以帮助我吗?
那是错误。
> [21:18:50 INFO]: [ELicense] Enabling ELicense v1.0
> [21:18:50 INFO]: Can't connect to database
> [21:18:50 WARN]: java.sql.SQLException: Unknown initial character set index '255' received from server. Initial client character set can be forced via the 'characterEncoding' property.
> [21:18:50 WARN]: at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
> [21:18:50 WARN]: at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
> [21:18:50 WARN]: at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
> [21:18:50 WARN]: at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
> [21:18:50 WARN]: at com.mysql.jdbc.ConnectionImpl.configureClientCharacterSet(ConnectionImpl.java:1794)
> [21:18:50 WARN]: at com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3523)
> [21:18:50 WARN]: at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2386)
> [21:18:50 WARN]: at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2163)
> [21:18:50 WARN]: at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
> [21:18:50 WARN]: at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
> [21:18:50 WARN]: at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> [21:18:50 WARN]: at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> [21:18:50 WARN]: at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> [21:18:50 WARN]: at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
> [21:18:50 WARN]: at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
> [21:18:50 WARN]: at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:378)
> [21:18:50 WARN]: at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
> [21:18:50 WARN]: at java.sql.DriverManager.getConnection(DriverManager.java:664)
> [21:18:50 WARN]: at java.sql.DriverManager.getConnection(DriverManager.java:270)
> [21:18:50 WARN]: at it.license.EatingSouls.DataManager.checkLicense(DataManager.java:26)
> [21:18:50 WARN]: at it.license.EatingSouls.Main.onEnable(Main.java:16)
> [21:18:50 WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321)
> [21:18:50 WARN]: at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340)
> [21:18:50 WARN]: at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405)
> [21:18:50 WARN]: at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357)
> [21:18:50 WARN]: at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317)
> [21:18:50 WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:414)
> [21:18:50 WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:378)
> [21:18:50 WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:333)
> [21:18:50 WARN]: at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:263)
> [21:18:50 WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525)
> [21:18:50 WARN]: at java.lang.Thread.run(Thread.java:748)
或者如果我更改登录系统,它将给我:
> [12:09:29 INFO]: [ELicense] Enabling ELicense v1.0
> [12:09:29 INFO]: Can't connect to database
> [12:09:29 WARN]: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client.
idk我该怎么解决。
那是代码
public static void checkLicense(String license) {
String l = license.replaceAll("'", "");
if(l != null && !l.equalsIgnoreCase("")) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(link);
String sql = "SELECT * FROM License WHERE license='"+ l +"' AND is_active='1'";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
if(!rs.next()) {
System.out.println("The license you entered is invalid or has been deactivated. Please enter a valid license!");
Bukkit.getPluginManager().disablePlugin(Main.me);
} else {
System.out.println("You are using a valid license!");
}
con.close();
}catch(Exception e) {
System.out.println("Can't connect to database");
e.printStackTrace();
Bukkit.shutdown();
}
} else {
System.out.println("Please insert a valid license!");
Bukkit.getPluginManager().disablePlugin(Main.me);
}
答案 0 :(得分:0)
确保服务器/数据库上具有最新的MySQL版本以及最新的依赖项。
步骤1:确保具有最新版本(依赖项和服务器)
步骤2:使用SQL查询:SELECT version();