Advertisement
Guest User

Untitled

a guest
Aug 7th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. /* */ package me.wazup.hideandseek;
  2. /* */
  3. /* */ import java.sql.Connection;
  4. /* */ import java.sql.SQLException;
  5. /* */ import org.bukkit.command.ConsoleCommandSender;
  6. /* */
  7. /* */ public class MySQL
  8. /* */ {
  9. /* 9 */ private Connection connection = null;
  10. /* */ private String url;
  11. /* */ private String username;
  12. /* */ private String password;
  13. /* */ String tableName;
  14. /* */
  15. /* */ public MySQL(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, String paramString6) {
  16. /* 16 */ this.url = ("jdbc:mysql://" + paramString2 + ":" + paramString3 + "/" + paramString4);
  17. /* 17 */ this.username = paramString5;
  18. /* 18 */ this.password = paramString6;
  19. /* 19 */ this.tableName = paramString1;
  20. /* 20 */ connect();
  21. /* */ }
  22. /* */
  23. /* */ public void connect() {
  24. /* */ try {
  25. /* 25 */ this.connection = java.sql.DriverManager.getConnection(this.url, this.username, this.password);
  26. /* 26 */ setupTable();
  27. /* */ } catch (SQLException localSQLException) {
  28. /* 28 */ main.plugin.console.sendMessage("[HideAndSeek] Failed to connect to mysql, please check if your mysql settings are correct in config.yml");
  29. /* 29 */ localSQLException.printStackTrace();
  30. /* */ }
  31. /* */ }
  32. /* */
  33. /* */ public Connection getConnection() {
  34. /* */ try {
  35. /* 35 */ if ((this.connection == null) || (!this.connection.isValid(3))) {
  36. /* 36 */ main.plugin.console.sendMessage("[HideAndSeek] Seems like the mysql connection was lost! attempting to reconnect");
  37. /* 37 */ Long localLong = Long.valueOf(System.currentTimeMillis());
  38. /* 38 */ connect();
  39. /* 39 */ main.plugin.console.sendMessage("[HideAndSeek] Reconnected successfully, took " + (System.currentTimeMillis() - localLong.longValue()) + "ms");
  40. /* */ }
  41. /* */ } catch (SQLException localSQLException) {
  42. /* 42 */ localSQLException.printStackTrace();
  43. /* */ }
  44. /* 44 */ return this.connection;
  45. /* */ }
  46. /* */
  47. /* */ public void setupTable() {
  48. /* */ try {
  49. /* 49 */ getConnection().createStatement().executeUpdate("create table if not exists " + this.tableName + " (player_name VARCHAR(20), player_uuid VARCHAR(60), hiders_killed int, seekers_killed int, wins int, coins int, karma int, games_played int, hider_chance int, play_time VARCHAR(30), exp int, modifier int, special_blocks VARCHAR(300), perks VARCHAR(100))");
  50. /* */ } catch (SQLException localSQLException) {
  51. /* 51 */ localSQLException.printStackTrace();
  52. /* */ }
  53. /* */ }
  54. /* */ }
  55.  
  56.  
  57. /* Location: C:\Users\Mihnea\Downloads\HideAndSeek3.jar!\me\wazup\hideandseek\MySQL.class
  58. * Java compiler version: 7 (51.0)
  59. * JD-Core Version: 0.7.1
  60. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement