Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.pixelfine.guistats;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- public class Database {
- private static Connection connection;
- private static void connect() {
- try {
- this.connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/uwbedwars", "root", "HfkIe3i73nM12FkE8pF";
- } catch (SQLException ex) {
- ex.printStackTrace();
- }
- }
- public static void close() {
- try {
- this.connection.close();
- } catch (SQLException ex) {}
- }
- public static int[] getBWStats(String playerName) {
- int Games = 0, Kills = 0, Wins = 0, Beds = 0;
- try {
- String query = "SELECT `Games`, `Kills`, `Wins`, `Beds` FROM `BedWars` WHERE `Name` LIKE '" + playerName + "'";
- Statement statement = this.getConnection().createStatement();
- ResultSet rs = statement.executeQuery(query);
- Games = rs.getInt(1); Kills = rs.getInt(2); Wins = rs.getInt(3); Beds = rs.getInt(4);
- statement.close(); rs.close();
- } catch (Exception Ex) {
- sqlEx.printStackTrace();
- }
- int stats[] = { Games, Kills, Wins, Beds };
- return stats;
- }
- static {
- connect();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement