Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.FairyTailSystem.MySQL;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import org.bukkit.Bukkit;
- import java.sql.Connection;
- public class MySQL {
- public static String username;
- public static String password;
- public static String database;
- public static String host;
- public static String port;
- public static Connection con;
- //MySQL connect
- public static void connect(){
- if(!isConnected()){
- try {
- con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
- Bukkit.getConsoleSender().sendMessage("§c[BanManager]§eDie Verbindung zu MySQL wurde erfolgreich hergestellt.");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- //MySQL disconnect
- public static void close(){
- if(isConnected()){
- try {
- con.close();
- Bukkit.getConsoleSender().sendMessage("§c[BanManager]§eDie Verbindung zu MySQL wurde erfolgreich geschlossen.");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- public static boolean isConnected(){
- return con != null;
- }
- //MySQL createTable
- public static void createTable(){
- if(isConnected()){
- try {
- con.createStatement().executeUpdate("CREATE TABLE IF NOT EXISTS `BannedPlayers` (`Spielername` VARCHAR(20), `UUID` VARCHAR(100), `Ende` VARCHAR(100), `Grund` VARCHAR(100)) DEFAULT CHARACTER SET='utf8'");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- //Kauderweltsch
- public static void update(String qry){
- if(isConnected()){
- try {
- con.createStatement().executeUpdate(qry);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- //GetResult
- public static ResultSet getResult(String qry){
- if(isConnected()){
- try {
- con.createStatement().executeQuery(qry);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- return null;
- }
- //
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement