From efc121257dfadd4ad903b4fffd3bb224a56374d5 Mon Sep 17 00:00:00 2001 From: BerndBreier <33351391+BerndBreier@users.noreply.github.com> Date: Tue, 26 Feb 2019 13:28:23 +0100 Subject: [PATCH] Use lowercase schema name if db is postgres. Hold the schemaname in TaskanaEngineConfiguration in lower case... --- .../configuration/TaskanaEngineConfiguration.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/taskana-core/src/main/java/pro/taskana/configuration/TaskanaEngineConfiguration.java b/lib/taskana-core/src/main/java/pro/taskana/configuration/TaskanaEngineConfiguration.java index 5823a972d..3e5b042b1 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/configuration/TaskanaEngineConfiguration.java +++ b/lib/taskana-core/src/main/java/pro/taskana/configuration/TaskanaEngineConfiguration.java @@ -5,6 +5,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.sql.Connection; import java.sql.SQLException; import java.time.Duration; import java.time.Instant; @@ -282,6 +283,17 @@ public class TaskanaEngineConfiguration { this.setSchemaName(DEFAULT_SCHEMA_NAME); } + try (Connection connection = dataSource.getConnection()) { + String databaseProductName = connection.getMetaData().getDatabaseProductName(); + if (TaskanaEngineImpl.isPostgreSQL(databaseProductName)) { + this.schemaName = this.schemaName.toLowerCase(); + } else { + this.schemaName = this.schemaName.toUpperCase(); + } + } catch (SQLException ex) { + LOGGER.error("Caught {} when attempting to initialize the schema name", ex); + } + LOGGER.debug("Using schema name {}", this.getSchemaName()); }