Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package eu.pixeldream.api.sql;
- import java.sql.Connection;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import eu.pixeldream.api.API;
- public class Mysql2 {
- private API plugin;
- private String HOST = null;
- private String DB = null;
- private String USER = null;
- private String PASS = null;
- private boolean connected = false;
- private Statement st = null;
- private Connection con = null;
- private MySQLFunc MySQL;
- public void MySQL()
- {
- this.plugin = API.getInstance();
- plugin.getDescription().getName();
- this.connected = false;
- }
- public Boolean Connect() {
- this.HOST = "localhost";
- this.DB = "network_servers";
- this.USER = "network_servers";
- this.PASS = "YN39gq2i";
- this.MySQL = new MySQLFunc(this.HOST, this.DB, this.USER, this.PASS);
- this.con = this.MySQL.open();
- try {
- this.st = this.con.createStatement();
- this.connected = true;
- } catch (SQLException e) {
- this.connected = false;
- e.printStackTrace();
- }
- try {
- this.st.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- this.MySQL.close(this.con);
- return Boolean.valueOf(this.connected);
- }
- public void update(String query) {
- this.MySQL = new MySQLFunc(this.HOST, this.DB, this.USER, this.PASS);
- this.con = this.MySQL.open();
- try {
- this.st = this.con.createStatement();
- this.st.execute(query);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- try {
- this.st.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- this.MySQL.close(this.con);
- }
- public ResultSet query(String query) {
- this.MySQL = new MySQLFunc(this.HOST, this.DB, this.USER, this.PASS);
- this.con = this.MySQL.open();
- ResultSet rs = null;
- try {
- this.st = this.con.createStatement();
- rs = this.st.executeQuery(query);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- try {
- this.st.close();
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- this.MySQL.close(this.con);
- return rs;
- }
- }
Add Comment
Please, Sign In to add comment