From 07e01246ea060a55b1cdb27e98a1ba6f14734ea5 Mon Sep 17 00:00:00 2001 From: QDIBYS Date: Thu, 11 Jul 2024 09:35:53 +0200 Subject: [PATCH] Revert "Use prepared statement in COUNT for execution log" This reverts commit 8c20e9477af5282f3c59e3c0accba05b910546d5. --- .../kraftwerk/core/outputs/csv/CsvOutputFiles.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/outputs/csv/CsvOutputFiles.java b/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/outputs/csv/CsvOutputFiles.java index 293233b4..f5222022 100644 --- a/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/outputs/csv/CsvOutputFiles.java +++ b/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/outputs/csv/CsvOutputFiles.java @@ -20,7 +20,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardOpenOption; -import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; @@ -98,14 +97,9 @@ public void writeOutputTables(Map metadataModels) throws //Count rows for functional log if (kraftwerkExecutionLog != null) { - String selectQuery = "SELECT COUNT(*) FROM ?"; - try(PreparedStatement preparedStatement = getDatabase().getConnection().prepareStatement(selectQuery)) { - preparedStatement.setString(1, datasetName); - try (ResultSet countResult = - preparedStatement.executeQuery()) { - countResult.next(); - kraftwerkExecutionLog.getLineCountByTableMap().put(datasetName, countResult.getInt(1)); - } + try(ResultSet countResult = this.getDatabase().executeQuery("SELECT COUNT(*) FROM " + datasetName)){ + countResult.next(); + kraftwerkExecutionLog.getLineCountByTableMap().put(datasetName, countResult.getInt(1)); } } } catch (SQLException | IOException e) {