Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.eliteSchwein.PRcore_addon;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- public class MySQL{
- public static String host = "localhost";
- public static String port = "3306";
- public static String database = "PRban";
- public static String username = "5spce59n6WKVGarv";
- public static String password = "5spce59n6WKVGarv";
- public static Connection con;
- public static void connect(){
- if(!isConnected()){
- try {
- con = DriverManager.getConnection("jdbc:mysql://PureResolution.net/PRban", username, password);// + host + "/" + database, username, password);
- System.out.println("[PRban-Mysql]verbunden");
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- public static void disconnect(){
- if(isConnected()){
- try {
- con.close();
- System.out.println("[PRban-Mysql]getrennt");
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- public static boolean isConnected(){
- return (con == null ? false : true);
- }
- public static void update(String qry){
- try {
- con.createStatement().executeUpdate(qry);
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public static ResultSet getResult(String qry){
- try {
- con.createStatement().executeQuery(qry);
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
- }
- public static void ExecuteCommand(String command)
- {
- try
- {
- if (con.isClosed()) {
- connect();
- }
- Statement st = con.createStatement();
- st.executeUpdate(command);
- }
- catch (SQLException e5)
- {
- System.out.println("[MySQLAPI] Fehler 04");
- System.out.println("[MySQLAPI] Es ist ein Fehler beim Ausfuehren des Befehls aufgetreten!");
- e5.printStackTrace();
- }
- }
- public static Connection getConnection(){
- return con;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement