From 8ca1d443759cef356fd9b62c739721781adf5403 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Mon, 27 Feb 2023 15:36:50 -0500 Subject: [PATCH] clean: add error message --- .../hibiscusmc/hmccosmetics/database/types/MySQLData.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/MySQLData.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/MySQLData.java index cc41a949..9298f931 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/MySQLData.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/MySQLData.java @@ -33,11 +33,12 @@ public class MySQLData extends SQLData { HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance(); try { openConnection(); + if (connection == null) throw new NullPointerException("Connection is null"); connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " + "(UUID varchar(36) PRIMARY KEY, " + "COSMETICS MEDIUMTEXT " + ");").execute(); - } catch (SQLException e) { + } catch (SQLException | NullPointerException e) { plugin.getLogger().severe(""); plugin.getLogger().severe(""); plugin.getLogger().severe("MySQL DATABASE CAN NOT BE REACHED."); @@ -94,7 +95,7 @@ public class MySQLData extends SQLData { public void close() { Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> { try { - if (connection == null) throw new NullPointerException(); + if (connection == null) throw new NullPointerException("Connection is null"); connection.close(); } catch (SQLException | NullPointerException e) { System.out.println(e.getMessage()); @@ -128,7 +129,7 @@ public class MySQLData extends SQLData { } try { - if (connection == null) throw new NullPointerException(); + if (connection == null) throw new NullPointerException("Connection is null"); ps = connection.prepareStatement(query); } catch (SQLException | NullPointerException e) { e.printStackTrace();