From 7266a2a875ed977d66dcb2913fab80656ff18bd6 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 14 Dec 2014 12:34:44 +1100 Subject: [PATCH] Possible fix... --- .../com/intellectualcrafters/plot/PlotMain.java | 7 +++++++ .../plot/database/SQLManager.java | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index 76de7f8e7..f70de0194 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -184,6 +184,13 @@ public class PlotMain extends JavaPlugin { */ private static LinkedHashMap> plots; + /** + * Return an instance of MySQL + */ + public static MySQL getMySQL() { + return mySQL; + } + /** * Check for expired plots */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index b7544c24b..432616194 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -53,7 +53,7 @@ public class SQLManager implements AbstractDB { public final String CREATE_HELPERS; public final String CREATE_PLOT; // Private Final - private final Connection connection; + private Connection connection; private final String prefix; /** @@ -81,6 +81,19 @@ public class SQLManager implements AbstractDB { "INSERT INTO `" + prefix + "plot_helpers` (`plot_plot_id`, `user_uuid`) values "; CREATE_PLOT = "INSERT INTO `" + prefix + "plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) VALUES(?, ?, ?, ?)"; + + //schedule reconnect + Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotMain.getMain(), new Runnable(){ + public void run(){ + try { + connection = PlotMain.getMySQL().openConnection(); + } + catch (Exception e) { + e.printStackTrace(); + } + } + }, 500000, 500000); + } public void setTimout() {