Addressing multi-databases from Java

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?

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