diff --git a/src/org/kar/archidata/db/DbIoFactory.java b/src/org/kar/archidata/db/DbIoFactory.java index 7d305e0..a455703 100644 --- a/src/org/kar/archidata/db/DbIoFactory.java +++ b/src/org/kar/archidata/db/DbIoFactory.java @@ -31,6 +31,7 @@ public class DbIoFactory { } final DbIo dbIo = createInstance(config); if (config.getKeepConnected()) { + dbIo.open(); dbIoStored.add(dbIo); } dbIo.open(); diff --git a/src/org/kar/archidata/db/DbIoMorphia.java b/src/org/kar/archidata/db/DbIoMorphia.java index fdaad05..6da68c2 100644 --- a/src/org/kar/archidata/db/DbIoMorphia.java +++ b/src/org/kar/archidata/db/DbIoMorphia.java @@ -26,10 +26,6 @@ public class DbIoMorphia extends DbIo implements Closeable { public DbIoMorphia(final DbConfig config) throws IOException { super(config); - // If we want to stay connected, we instantiate a basic connection (only force close can remove it). - if (this.config.getKeepConnected()) { - open(); - } } public Datastore getDatastore() { diff --git a/src/org/kar/archidata/db/DbIoSql.java b/src/org/kar/archidata/db/DbIoSql.java index b043876..09570e3 100644 --- a/src/org/kar/archidata/db/DbIoSql.java +++ b/src/org/kar/archidata/db/DbIoSql.java @@ -15,10 +15,6 @@ public class DbIoSql extends DbIo { public DbIoSql(final DbConfig config) throws IOException { super(config); - // If we want to stay connected, we instantiate a basic connection (only force close can remove it). - if (this.config.getKeepConnected()) { - open(); - } } public Connection getConnection() { diff --git a/test/src/test/kar/archidata/ConfigureDb.java b/test/src/test/kar/archidata/ConfigureDb.java index 761c2d1..b15ff1d 100644 --- a/test/src/test/kar/archidata/ConfigureDb.java +++ b/test/src/test/kar/archidata/ConfigureDb.java @@ -122,14 +122,15 @@ public class ConfigureDb { da.deleteDB(ConfigBaseVariable.bdDatabase); } else if ("MONGO".equalsIgnoreCase(modeTest)) { da.deleteDB(ConfigBaseVariable.bdDatabase); - } else {} + } } public static void clear() throws IOException { LOGGER.info("Remove the test db"); removeDB(); + // The connection is by default open ==> close it at the end of test: + da.close(); DbIoFactory.closeAllForceMode(); ConfigBaseVariable.clearAllValue(); - da.close(); } }