Hey meine lieben.
wie immer ein Problem. Ich bin seid ungefähr 8h dran ein StatsSystem zu programmieren.
Jetzt mache ich es über Mysql weil performace und so.
ich sag gleich hier ist der code. ich weiß nicht was daran falsch sein soll.
Ja die Connection werd erstellt und funkt!!!!
Und in der Main wird dann das so gemacht:
Und in der onDisable wird die MySQL wieder geschlossen....
bitte hift mir ;(
wie immer ein Problem. Ich bin seid ungefähr 8h dran ein StatsSystem zu programmieren.
Jetzt mache ich es über Mysql weil performace und so.
ich sag gleich hier ist der code. ich weiß nicht was daran falsch sein soll.
Ja die Connection werd erstellt und funkt!!!!
Code:
package me.skypvpsystem.mysql;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class MySQL {
private static String HOST = "NONE";
private static String PORT = "NONE";
private static String DATABASE = "NONE";
private static String USER = "NONE";
private static String PASSWORD = "NONE";
private static Connection con;
public static void connect() {
if(!isConnected()) {
try {
con = DriverManager.getConnection("jdbc:mysql://" + HOST + ":" + PORT + "/" + DATABASE, USER, PASSWORD);
System.out.print("[MySQL] Verbindung wurde hergestellt");
} catch (SQLException e) {}
}
}
public static void disconnect() {
if(isConnected()) {
try {
con.close();
System.out.print("[MySQL] Verbindung wurde getrennt");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public static boolean isConnected() {
return (con == null ? false : true);
}
public static void update(String qry) {
try {
Statement st = con.createStatement();
st.executeUpdate(qry);
st.close();
} catch (SQLException e) {}
}
public static ResultSet getResult(String qry) {
ResultSet rs = null;
try {
Statement st = con.createStatement();
rs = st.executeQuery(qry);
} catch (SQLException e) {}
return rs;
}
}
Code:
@Override
public void onEnable() {
instance = this;
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
loadEvents();
loadCommands();
loadConfig();
CreateTopRanks.loadList();
startScoreboard();
SB.loadTeam();
Nick.loadNick();
KitSystem.loadKit();
if(getConfig().getBoolean("AutoMessage.Allow") == true) {
Automessage.onStart();
}
MySQL.connect();
MySQL.update("CREATE TABLE IF NOT EXISTS Stats (UUID VARCHAR(100),KILLS INT(100),DEATHS INT(100),COINS(100))");
}
Und in der onDisable wird die MySQL wieder geschlossen....
bitte hift mir ;(