Skip to content

Commit

Permalink
AgentDB: remove the fact that AgentDB does not support the connection to
Browse files Browse the repository at this point in the history
a SQLite database.
Note that: when having several AgentDB trying to update the same file,
there will be an exception as the DB file is locked.
We should advice to have a single agentDB connected to a single file.
  • Loading branch information
benoitgaudou committed Jun 13, 2020
1 parent d384e06 commit 54c0e7b
Showing 1 changed file with 11 additions and 8 deletions.
Expand Up @@ -20,7 +20,6 @@
import msi.gama.precompiler.GamlAnnotations.action;
import msi.gama.precompiler.GamlAnnotations.arg;
import msi.gama.precompiler.GamlAnnotations.doc;
import msi.gama.precompiler.GamlAnnotations.example;
import msi.gama.precompiler.GamlAnnotations.species;
import msi.gama.runtime.IScope;
import msi.gama.runtime.exceptions.GamaRuntimeException;
Expand Down Expand Up @@ -138,14 +137,18 @@ public Object connectDB(final IScope scope) throws GamaRuntimeException {

params = (java.util.Map<String, String>) scope.getArg("params", IType.MAP);

final String dbtype = params.get("dbtype");

// Note BG: before 13/06/2020, SQLite was not supported in AgentDB.
// The reason is not clear, a guess is that when an agent update the database file,
// the file is locked and thus another agent cannot try to update it.
// As a consequence it is recommended to have a single AgentDB connected to SQLite DB file.

// final String dbtype = params.get("dbtype");
// SqlConnection sqlConn;
if (dbtype.equalsIgnoreCase(SqlConnection.SQLITE)) {
throw GamaRuntimeException.error(
"AgentDB.connection to SQLite error: an AgentDB agent cannot connect to SQLite DBMS (cf. documentation for further info).",
scope);
}
// if (dbtype.equalsIgnoreCase(SqlConnection.SQLITE)) {
// throw GamaRuntimeException.error(
// "AgentDB.connection to SQLite error: an AgentDB agent cannot connect to SQLite DBMS (cf. documentation for further info).",
// scope);
// }
if (isConnection) {
throw GamaRuntimeException.error("AgentDB.connection error: a connection is already opened", scope);
}
Expand Down

0 comments on commit 54c0e7b

Please sign in to comment.