Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.noelbank.mysql;
- import java.io.PrintStream;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- public class mysql
- {
- public static String host = "127.0.0.1";
- public static String port = "3306";
- public static String database = "mcrpg";
- public static String username = "minecraft";
- public static String password = "failfail1";
- public static Connection con;
- public static void connect()
- {
- if (!isConnected()) {
- try
- {
- con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
- System.out.println("[MYSQL] +");
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- }
- public static void disconnect()
- {
- if (isConnected()) {
- try
- {
- con.close();
- System.out.println("[MYSQL] -");
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- }
- public static boolean isConnected()
- {
- return con != null;
- }
- public static boolean getMYSQL()
- {
- if (!isConnected()) {
- try
- {
- con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- return true;
- }
- public static Connection getConnection()
- {
- return con;
- }
- public static void update(String qry)
- {
- if (isConnected()) {
- try
- {
- con.createStatement().executeUpdate(qry);
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- }
- public static ResultSet getResult(String qrv)
- {
- if (isConnected()) {
- try
- {
- con.createStatement().executeQuery(qrv);
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- return null;
- }
- public static boolean isBanned(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM banns WHERE UUID='" + uuid + "'");
- return rs.next();
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return false;
- }
- public static boolean isunBanned(String name)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM banns WHERE name='" + name + "'");
- return rs.next();
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return false;
- }
- public static String getReason(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM banns WHERE UUID= '" + uuid + "'");
- if (rs.next()) {
- return rs.getString("cause");
- }
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return "";
- }
- public static String getTime(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM banns WHERE UUID='" + uuid + "'");
- if (rs.next()) {
- return rs.getString("time");
- }
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return "";
- }
- public static String getIP(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM banns WHERE UUID='" + uuid + "'");
- if (rs.next()) {
- return rs.getString("ip");
- }
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return "";
- }
- public static String getID(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM banns WHERE UUID='" + uuid + "'");
- if (rs.next()) {
- return rs.getString("id");
- }
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return "";
- }
- public static boolean isMuted(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM muted WHERE UUID='" + uuid + "'");
- return rs.next();
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return false;
- }
- public static String getMute(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM muted WHERE UUID='" + uuid + "'");
- if (rs.next()) {
- return rs.getString("grund");
- }
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return "";
- }
- public static boolean isWartungon(String way)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM system WHERE wartung='" + way + "'");
- return rs.next();
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return false;
- }
- public static boolean isWartung(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM wartung WHERE UUID='" + uuid + "'");
- return rs.next();
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return false;
- }
- public static boolean isunWartung(String name)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM wartung WHERE name='" + name + "'");
- return rs.next();
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return false;
- }
- public static boolean isJob(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM jobs WHERE UUID='" + uuid + "'");
- return rs.next();
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return false;
- }
- public static String getHolz(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM jobs WHERE UUID='" + uuid + "'");
- if (rs.next()) {
- return rs.getString("holz");
- }
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return "";
- }
- public static String getMining(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM jobs WHERE UUID='" + uuid + "'");
- if (rs.next()) {
- return rs.getString("mining");
- }
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return "";
- }
- public static String getJob(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM jobs WHERE UUID='" + uuid + "'");
- if (rs.next()) {
- return rs.getString("job");
- }
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return "";
- }
- public static boolean isAbschluss(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM schule WHERE UUID='" + uuid + "'");
- return rs.next();
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return false;
- }
- public static boolean isabAbschluss(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT abschluss FROM schule WHERE UUID='" + uuid + "'");
- return rs.next();
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return false;
- }
- public static String getGehalt(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM schule WHERE UUID='" + uuid + "'");
- if (rs.next()) {
- return rs.getString("gehalt");
- }
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return "";
- }
- public static long getLohn(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM schule WHERE UUID='" + uuid + "'");
- if (rs.next()) {
- return rs.getLong("lohn");
- }
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return 0L;
- }
- public static String getAbschluss(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM schule WHERE UUID='" + uuid + "'");
- if (rs.next()) {
- return rs.getString("abschluss");
- }
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return "";
- }
- public static boolean isAbsH(String way)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM schule WHERE wartung='" + way + "'");
- return rs.next();
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return false;
- }
- public static String getAusbildung(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM schule WHERE UUID='" + uuid + "'");
- if (rs.next()) {
- return rs.getString("ausbildung");
- }
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return "";
- }
- public static String getBeruf(String uuid)
- {
- try
- {
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("SELECT * FROM schule WHERE UUID='" + uuid + "'");
- if (rs.next()) {
- return rs.getString("beruf");
- }
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return "";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement