Guest User

Untitled

a guest
May 21st, 2017
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.17 KB | None | 0 0
  1. package eu.pixeldream.api.sql;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.ResultSet;
  5. import java.sql.SQLException;
  6. import java.sql.Statement;
  7.  
  8. import eu.pixeldream.api.API;
  9.  
  10. public class Mysql2 {
  11.       private API plugin;
  12.       private String HOST = null;
  13.       private String DB = null;
  14.       private String USER = null;
  15.       private String PASS = null;
  16.       private boolean connected = false;
  17.  
  18.       private Statement st = null;
  19.       private Connection con = null;
  20.       private MySQLFunc MySQL;
  21.      
  22.       public void MySQL()
  23.       {
  24.         this.plugin = API.getInstance();
  25.         plugin.getDescription().getName();
  26.         this.connected = false;
  27.       }
  28.  
  29.   public Boolean Connect() {
  30.     this.HOST = "localhost";
  31.     this.DB = "network_servers";
  32.     this.USER = "network_servers";
  33.     this.PASS = "YN39gq2i";
  34.     this.MySQL = new MySQLFunc(this.HOST, this.DB, this.USER, this.PASS);
  35.     this.con = this.MySQL.open();
  36.     try {
  37.       this.st = this.con.createStatement();
  38.       this.connected = true;
  39.     } catch (SQLException e) {
  40.       this.connected = false;
  41.       e.printStackTrace();
  42.     }
  43.     try {
  44.         this.st.close();
  45.     } catch (SQLException e) {
  46.         e.printStackTrace();
  47.     }
  48.     this.MySQL.close(this.con);
  49.     return Boolean.valueOf(this.connected);
  50.   }
  51.  
  52.   public void update(String query) {
  53.     this.MySQL = new MySQLFunc(this.HOST, this.DB, this.USER, this.PASS);
  54.     this.con = this.MySQL.open();
  55.     try {
  56.       this.st = this.con.createStatement();
  57.       this.st.execute(query);
  58.     } catch (SQLException e) {
  59.         e.printStackTrace();
  60.     }
  61.     try {
  62.         this.st.close();
  63.     } catch (SQLException e) {
  64.         e.printStackTrace();
  65.     }
  66.     this.MySQL.close(this.con);
  67.   }
  68.  
  69.   public ResultSet query(String query) {
  70.     this.MySQL = new MySQLFunc(this.HOST, this.DB, this.USER, this.PASS);
  71.     this.con = this.MySQL.open();
  72.     ResultSet rs = null;
  73.     try {
  74.       this.st = this.con.createStatement();
  75.       rs = this.st.executeQuery(query);
  76.     } catch (SQLException e) {
  77.         e.printStackTrace();
  78.     }
  79.     try {
  80.         this.st.close();
  81.     } catch (SQLException e) {
  82.         // TODO Auto-generated catch block
  83.         e.printStackTrace();
  84.     }
  85.     this.MySQL.close(this.con);
  86.     return rs;
  87.   }
  88. }
Add Comment
Please, Sign In to add comment