Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-09-2020 08:28 AM
Dear community,
I started having a go at multi-databases. I get how you can create and switch between databases in the browser by e.g.
:use system
create database newDatabase
:use newDatabase
Is it also possible to achieve the same using a java programme?
I have in mind something like:
...
session = driver.session();
session.writeTransaction((Transaction tx) -> {
tx.run(":use system");
return 1;
});
session.writeTransaction((Transaction tx) -> {
tx.run("create database newDatabase");
return 1;
});
session.writeTransaction((Transaction tx) -> {
tx.run(":use newDatabase");
return 1;
});
Has anyone done anything similar?
03-11-2020 12:10 PM
I don't believe you can change databases within a session.
The database you connect to is specified at session creation time via SessionConfig. The default session config chooses the default database of the server.
Docs here: https://neo4j.com/docs/driver-manual/current/cypher-workflow/#driver-databases
All the sessions of the conference are now available online