Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* */ package me.wazup.hideandseek;
- /* */
- /* */ import java.sql.Connection;
- /* */ import java.sql.SQLException;
- /* */ import org.bukkit.command.ConsoleCommandSender;
- /* */
- /* */ public class MySQL
- /* */ {
- /* 9 */ private Connection connection = null;
- /* */ private String url;
- /* */ private String username;
- /* */ private String password;
- /* */ String tableName;
- /* */
- /* */ public MySQL(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, String paramString6) {
- /* 16 */ this.url = ("jdbc:mysql://" + paramString2 + ":" + paramString3 + "/" + paramString4);
- /* 17 */ this.username = paramString5;
- /* 18 */ this.password = paramString6;
- /* 19 */ this.tableName = paramString1;
- /* 20 */ connect();
- /* */ }
- /* */
- /* */ public void connect() {
- /* */ try {
- /* 25 */ this.connection = java.sql.DriverManager.getConnection(this.url, this.username, this.password);
- /* 26 */ setupTable();
- /* */ } catch (SQLException localSQLException) {
- /* 28 */ main.plugin.console.sendMessage("[HideAndSeek] Failed to connect to mysql, please check if your mysql settings are correct in config.yml");
- /* 29 */ localSQLException.printStackTrace();
- /* */ }
- /* */ }
- /* */
- /* */ public Connection getConnection() {
- /* */ try {
- /* 35 */ if ((this.connection == null) || (!this.connection.isValid(3))) {
- /* 36 */ main.plugin.console.sendMessage("[HideAndSeek] Seems like the mysql connection was lost! attempting to reconnect");
- /* 37 */ Long localLong = Long.valueOf(System.currentTimeMillis());
- /* 38 */ connect();
- /* 39 */ main.plugin.console.sendMessage("[HideAndSeek] Reconnected successfully, took " + (System.currentTimeMillis() - localLong.longValue()) + "ms");
- /* */ }
- /* */ } catch (SQLException localSQLException) {
- /* 42 */ localSQLException.printStackTrace();
- /* */ }
- /* 44 */ return this.connection;
- /* */ }
- /* */
- /* */ public void setupTable() {
- /* */ try {
- /* 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))");
- /* */ } catch (SQLException localSQLException) {
- /* 51 */ localSQLException.printStackTrace();
- /* */ }
- /* */ }
- /* */ }
- /* Location: C:\Users\Mihnea\Downloads\HideAndSeek3.jar!\me\wazup\hideandseek\MySQL.class
- * Java compiler version: 7 (51.0)
- * JD-Core Version: 0.7.1
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement