From 6298697169b578c7432d48dad58c46fda381a2ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Mon, 24 Oct 2022 22:44:12 +0200 Subject: [PATCH] Fix SQL issue --- .../wtf/beatrice/nounspicker/utils/DatabaseManager.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/wtf/beatrice/nounspicker/utils/DatabaseManager.java b/src/main/java/wtf/beatrice/nounspicker/utils/DatabaseManager.java index 6901d0a..4564437 100644 --- a/src/main/java/wtf/beatrice/nounspicker/utils/DatabaseManager.java +++ b/src/main/java/wtf/beatrice/nounspicker/utils/DatabaseManager.java @@ -336,8 +336,8 @@ public class DatabaseManager if(!isInTable(playerName)) return -1; - String query = "SELECT ? FROM players " + - "WHERE player = ? " + + String query = "SELECT %param% FROM players " + + "WHERE player=? " + "LIMIT 1"; @@ -348,11 +348,12 @@ public class DatabaseManager String priorityStr = ""; if(priority == 0) priorityStr = "main_pronoun_id"; else if(priority == 1) priorityStr = "secondary_pronoun_id"; + query = query.replace("%param%", priorityStr); try(PreparedStatement pStatement = dbConnection.prepareStatement(query)) { - pStatement.setString(1, priorityStr); - pStatement.setString(2, playerName); + pStatement.setString(1, playerName); + ResultSet rSet = pStatement.executeQuery(); if(rSet.isClosed()) return -1;