Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.snics.straf;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.util.HashMap;
- import org.bukkit.plugin.Plugin;
- import com.mysql.jdbc.PreparedStatement;
- public abstract class MySQL implements Plugin
- {
- static Connection connection;
- String prefix = "§f§l[§c§lLABEL§f§l] §r";
- static HashMap<String, String> playerPunish = new HashMap<String, String>();
- static HashMap<String, String> punisher = new HashMap<String, String>();
- static HashMap<String, String> reason = new HashMap<String, String>();
- public synchronized void onDisable()
- {
- try
- {
- if(connection != null && !connection.isClosed())
- {
- connection.close();
- }
- }
- catch (Exception e1)
- {
- e1.printStackTrace();
- }
- }
- public static synchronized void openConnection()
- {
- try
- {
- connection = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/straf", "root", "Pidiboe002");
- }
- catch (Exception e1)
- {
- e1.printStackTrace();
- }
- }
- public static synchronized void closeConnection()
- {
- try
- {
- connection.close();
- }
- catch (Exception e1)
- {
- e1.printStackTrace();
- }
- }
- public static synchronized boolean playerdataContainsPlayer(String args)
- {
- openConnection();
- try
- {
- PreparedStatement sql = (PreparedStatement) connection.prepareStatement("SELECT * FROM `player_data` WHERE player_name=?;");
- sql.setString(1, args);
- ResultSet result = sql.executeQuery();
- boolean containsPlayer = result.next();
- sql.close();
- result.close();
- return containsPlayer;
- }
- catch (Exception e1)
- {
- e1.printStackTrace();
- }
- finally
- {
- closeConnection();
- }
- return true;
- }
- }
Add Comment
Please, Sign In to add comment