private SpeedhuntLobby hunt; //MAIN private Connection connection; private String host; private String database; private String username; private String password; private int port; public SQLUtil(SpeedhuntLobby hunt, String host, String database, String username, String password, int port) { this.hunt = hunt; this.host = host; this.database = database; this.username = username; this.password = password; this.port = port; } public void openConnection() { try { if (connection != null && !connection.isClosed()) { return; } Class.forName("com.mysql.jdbc.Driver"); connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password); } catch (Exception e) { Bukkit.broadcastMessage("SQL Exception"); } } public ResultSet getResult(String input) { try { return connection.createStatement().executeQuery(input); } catch (SQLException e) { e.printStackTrace(); } return null; } public void createTable() { Bukkit.getScheduler().runTaskAsynchronously(hunt, () -> { try { openConnection(); connection.createStatement().executeUpdate("CREATE TABLE IF NOT EXISTS Speedhuntdata (USERID CHAR(36), WINS INT, DEATHS INT, GAMES INT, WINEFFECT VARCHAR(40), PRIMARY KEY(USERID));"); connection.close(); } catch (SQLException e) { e.printStackTrace(); } }); }