1.8.8 My server is cached by PreparedStatement MySQL

Discussion in 'Spigot Plugin Development' started by NongFILLTH, Apr 1, 2020.

  1. My server Currently, there are people I want to know why that person is 800-1000. It has also This is the code through some fault of mine.
    Code (Text):

    [13:24:25] [Spigot Watchdog Thread/ERROR]: Current Thread: Async Chat Thread - #96
    [13:24:25] [Spigot Watchdog Thread/ERROR]:     PID: 1395 | Suspended: false | Native: false | State: BLOCKED
    [13:24:25] [Spigot Watchdog Thread/ERROR]:     Stack:
    [13:24:25] [Spigot Watchdog Thread/ERROR]:         com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2182)
    [13:24:25] [Spigot Watchdog Thread/ERROR]:         com.fewfond.seksin.api.label.Label.getLabel(Label.java:24)
    [13:24:25] [Spigot Watchdog Thread/ERROR]:         com.fewfond.seksin.event.Chat.onChat(Chat.java:51)
    [13:24:25] [Spigot Watchdog Thread/ERROR]:         sun.reflect.GeneratedMethodAccessor309.invoke(Unknown Source)
    [13:24:25] [Spigot Watchdog Thread/ERROR]:         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [13:24:25] [Spigot Watchdog Thread/ERROR]:         java.lang.reflect.Method.invoke(Method.java:498)
    [13:24:25] [Spigot Watchdog Thread/ERROR]:         org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306)
    [13:24:25] [Spigot Watchdog Thread/ERROR]:         org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
    [13:24:25] [Spigot Watchdog Thread/ERROR]:         org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502)
    [13:24:25] [Spigot Watchdog Thread/ERROR]:         org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:484)
    [13:24:25] [Spigot Watchdog Thread/ERROR]:         net.minecraft.server.v1_8_R3.PlayerConnection.chat(PlayerConnection.java:1084)
    [13:24:25] [Spigot Watchdog Thread/ERROR]:         net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1022)
    [13:24:25] [Spigot Watchdog Thread/ERROR]:         net.minecraft.server.v1_8_R3.PacketPlayInChat$1.run(PacketPlayInChat.java:39)
    [13:24:25] [Spigot Watchdog Thread/ERROR]:         java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    [13:24:25] [Spigot Watchdog Thread/ERROR]:         java.util.concurrent.FutureTask.run(FutureTask.java:266)
    [13:24:25] [Spigot Watchdog Thread/ERROR]:         java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    [13:24:25] [Spigot Watchdog Thread/ERROR]:         java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    [13:24:25] [Spigot Watchdog Thread/ERROR]:         java.lang.Thread.run(Thread.java:748)
     
    And the details of the plugin my files.
    Code (Java):
    public static LabelType getLabel(String playername, int type) {
            LabelType suffix = null;
            String typer = "";
            if (type == 1) {
                typer = "Label1";
            } else {
                typer = "Label2";
            }
            try {
                PreparedStatement statement = Main.getConnection().prepareStatement("SELECT * FROM playerdata WHERE Username=?");
                statement.setString(1, playername);
                ResultSet res = statement.executeQuery();
                if (res.next()) {
                    if (res.getString(typer).equalsIgnoreCase("N/A")) {
                        suffix = null;
                    } else {
                        suffix = LabelType.valueOf(res.getString(typer));
                    }
                }
                res.close();
                statement.close();
            } catch (SQLException e) {
                suffix = null;
                Bukkit.getConsoleSender().sendMessage("§c[ERROR] : Error execute query (get label)");
                Bukkit.getConsoleSender().sendMessage("§c[ERROR] : " + e.getMessage());
            }
            return suffix;
        }
    Sorry my English