Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.rs2hd.packethandler;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import com.rs2hd.model.PlayerDetails;
- import com.rs2hd.model.Skills;
- import com.rs2hd.model.Player;
- /*
- /*Author @ RuneUnited
- */
- public class MYSQL {
- public static Connection con = null;
- public static Statement stmt;
- public static boolean connectionMade;
- public static void createConnection() {
- try {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- String IP="184.22.145.77";
- String DB="runeunit_vote";
- String User="runeunit_vote";
- String Pass="gears2pwnage";
- con = DriverManager.getConnection("jdbc:mysql://"+IP+"/"+DB, User, Pass);
- stmt = con.createStatement();
- //System.out.println("Connection to Votes database successful!");
- } catch (Exception e) {
- System.out.println("Connection to Votes database failed");
- e.printStackTrace();
- }
- }
- 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) {
- destroyConnection();
- }
- return null;
- }
- public static void destroyConnection() {
- try {
- stmt.close();
- con.close();
- } catch (Exception e) {
- }
- }
- public static boolean checkVotes(String playerName) {
- try {
- String name2 = playerName.replaceAll("_", " ");
- Statement statement = con.createStatement();
- String query = "SELECT * FROM Votes WHERE username = '" + name2 + "'";
- ResultSet results = statement.executeQuery(query);
- while(results.next()) {
- int recieved = results.getInt("recieved");
- if(recieved == 0)
- {
- return true;
- }
- }
- } catch(SQLException e) {
- e.printStackTrace();
- }
- return false;
- }
- public static boolean voteGiven(String playerName)
- {
- try
- { String name2 = playerName.replaceAll("_", " ");
- query("UPDATE Votes SET recieved = 1 WHERE username = '" + name2 + "'");
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- return true;
- }
- /**
- /* @ RuneUnited Auto Donation
- **/
- public static boolean checkDonation(String playerName)
- {
- try {
- Statement statement = con.createStatement();
- String query = "SELECT * FROM donation WHERE username = '" + playerName + "'";
- ResultSet results = statement.executeQuery(query);
- while(results.next()) {
- int tickets = results.getInt("tickets");
- if(tickets == 1)
- {
- return true;
- }
- }
- } catch(SQLException e) {
- e.printStackTrace();
- }
- return false;
- }
- public static int checkDonationItem(String playerName)
- {
- try {
- Statement statement = con.createStatement();
- String query = "SELECT * FROM donation WHERE username = '" + playerName + "'";
- ResultSet results = statement.executeQuery(query);
- while(results.next()) {
- int productid = results.getInt("productid");
- if(productid >= 1) {
- return productid;
- }
- }
- } catch(SQLException e) {
- e.printStackTrace();
- }
- return 0;
- }
- }
Add Comment
Please, Sign In to add comment