Advertisement
xIKilleRzI

MySQL

Feb 22nd, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. package MySQL;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.ResultSet;
  6. import java.sql.SQLException;
  7. import java.sql.Statement;
  8. import java.util.concurrent.TimeUnit;
  9.  
  10.  
  11. public class MySQL {
  12.  
  13. public static Connection Connection;
  14.  
  15. static int count = 0;
  16. public static void CreateDBS(){
  17. MySQL.Connecting();
  18. try {
  19. Connection.prepareStatement("CREATE TABLE IF NOT EXISTS `table` ( `cloum` VARCHAR(100) NOT NULL) ENGINE = InnoDB;").execute();
  20.  
  21. } catch (SQLException sql) {
  22. }
  23.  
  24. BungeeCord.getInstance().getScheduler().schedule(Main.instance, new Runnable() {
  25. public void run() {
  26. try {
  27. if (MySQL.Connection == null || MySQL.Connection.isClosed()) {
  28. MySQL.Connecting();
  29. }
  30. } catch (SQLException e) {
  31. }
  32. }
  33. }, 0, 20, TimeUnit.SECONDS);
  34. }
  35.  
  36. public static synchronized void Connecting() {
  37. try {
  38. Connection = DriverManager.getConnection("jdbc:mysql://54.36.111.101:3306/" + "database" + "?autoreconnect=true&useSSL=false", "user", "pass");
  39. } catch (Exception sql) {
  40. }
  41. }
  42.  
  43. public static ResultSet getResult(String qry) {
  44. ResultSet rs = null;
  45. try {
  46. Statement st = Connection.createStatement();
  47. rs = st.executeQuery(qry);
  48. } catch (SQLException e) {
  49. }
  50. return rs;
  51. }
  52.  
  53. public static boolean ScanSettings(String uuid) {
  54. boolean bool = false;
  55. try {
  56. ResultSet rs = MySQL.getResult("SELECT * FROM `Settings` WHERE UUID='" + uuid + "'");
  57. if(rs.next()) {
  58. bool = true;
  59. }
  60. } catch (SQLException e) {
  61. System.out.println("Friends ScanSettings: " + e.getMessage());
  62. }
  63. return bool;
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement