From 45101901bd6fcc235162376392d177ac95170604 Mon Sep 17 00:00:00 2001 From: Tastybento Date: Sat, 21 Apr 2018 11:41:48 -0700 Subject: [PATCH] Fixed loadObject for MySQL. The uniqueKey needs to be enclosed in quotes "" to work. --- .../bskyblock/database/mysql/MySQLDatabaseHandler.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/us/tastybento/bskyblock/database/mysql/MySQLDatabaseHandler.java b/src/main/java/us/tastybento/bskyblock/database/mysql/MySQLDatabaseHandler.java index 631126b18..4c459d3fc 100644 --- a/src/main/java/us/tastybento/bskyblock/database/mysql/MySQLDatabaseHandler.java +++ b/src/main/java/us/tastybento/bskyblock/database/mysql/MySQLDatabaseHandler.java @@ -95,7 +95,7 @@ public class MySQLDatabaseHandler extends AbstractDatabaseHandler { public List loadObjects() { List list = new ArrayList<>(); StringBuilder sb = new StringBuilder(); - sb.append("SELECT `json` FROM `"); + sb.append("SELECT `json` FROM `"); sb.append(dataObject.getCanonicalName()); sb.append("`"); try (Statement preparedStatement = connection.createStatement()) { @@ -115,11 +115,12 @@ public class MySQLDatabaseHandler extends AbstractDatabaseHandler { @Override public T loadObject(String uniqueId) { StringBuilder sb = new StringBuilder(); - sb.append("SELECT `json` FROM `"); + sb.append("SELECT `json` FROM `"); sb.append(dataObject.getCanonicalName()); sb.append("` WHERE uniqueId = ? LIMIT 1"); try (PreparedStatement preparedStatement = connection.prepareStatement(sb.toString())) { - preparedStatement.setString(1, uniqueId); + // UniqueId needs to be placed in quotes + preparedStatement.setString(1, "\"" + uniqueId + "\""); try (ResultSet resultSet = preparedStatement.executeQuery()) { while (resultSet.next()) { // If there is a result, we only want/need the first one