[CONNECTIONS]

- aggiunto destroy delle connessioni prima della reinizalizzazione post modifiche ad ems-settings
    - aggiunta eccezzione in getConnection se la connessione stabilita ha un db diverso da quello richiesto
This commit is contained in:
2025-09-12 12:52:55 +02:00
parent 9fdc1f6b0e
commit e02fe6c36c
2 changed files with 7 additions and 1 deletions

View File

@@ -55,6 +55,7 @@ public class EmsCoreDBLoader {
public void init() throws Exception {
this.settingsController.addOnConfigUpdated(() -> {
try {
connectionPool.destroy();
connectionPool.init();
load(null);
} catch (Exception e) {

View File

@@ -96,7 +96,12 @@ public class BasicConnectionPool {
throw new IllegalArgumentException("No datasource registered for profile: " + connectionsModel.getProfileName());
}
return ds.getConnection();
Connection connection = ds.getConnection();
if (!connection.getCatalog().equalsIgnoreCase(dbName)) {
throw new IllegalArgumentException("Connection for profile " + connectionsModel.getProfileName() + " is not for database " + dbName);
}
return connection;
} catch (Exception e) {
throw new RuntimeException(e);