Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package server.model.players;
- import java.sql.*;
- import server.model.players.*;
- public class clanocideTeams {
- public static Connection connection;
- public static Statement stmt;
- public static ResultSet results;
- public static boolean connected;
- public static String Host = "jdbc:mysql://HOST/DATABASE";
- public static String User = "USERNAME";
- public static String Pass = "PASSWORD";
- private Client c;
- /**
- * Creates the connection to the database
- */
- public static void connectToDatabase() {
- try {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- Connection con = DriverManager.getConnection(Host, User, Pass);
- stmt = con.createStatement();
- connected = true;
- } catch (Exception e) {
- connected = false;
- e.printStackTrace();
- }
- }
- /**
- * destroys the connection to the database
- */
- public static void destroyCon() {
- try {
- stmt.close();
- connection.close();
- } catch (Exception e) {
- }
- }
- public static ResultSet query(String s) throws SQLException {
- try {
- if (s.toLowerCase().startsWith("select")) {
- ResultSet rs = stmt.executeQuery(s);
- return rs;
- } else {
- stmt.executeUpdate(s);
- }
- return null;
- } catch (Exception e) {
- destroyCon();
- connectToDatabase();
- }
- return null;
- }
- public static boolean saveClanocideKills(Client client) {
- try {
- //TODO
- } catch (Exception e) {
- //e.printStackTrace();
- return false;
- }
- return true;
- }
- public static boolean saveClanocideDeaths(Client client) {
- try {
- //TODO
- } catch (Exception e) {
- //e.printStackTrace();
- return false;
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement