0
我需要以编程方式创建Neo4j数据库,然后更改初始密码。创建数据库的工作,但我不知道如何更改密码。如何在以Java编程创建Neo4j数据库时更改初始密码
String graphDBFilePath = Config.getNeo4jFilesPath_Absolute() + "/" + schemaName; // This is an absolute path. Do not let Neo4j see it.
GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(new File(graphDBFilePath)); // See http://neo4j.com/docs/java-reference/current/javadocs/org/neo4j/graphdb/GraphDatabaseService.html
// This transaction works
try (Transaction tx = graphDb.beginTx()) {
Node myNode = graphDb.createNode();
myNode.setProperty("name", "my node");
tx.success();
}
// This transaction throws an error
Transaction tx = graphDb.beginTx();
try {
graphDb.execute("CALL dbms.changePassword(\'Danger42\')"); // "Invalid attempt to change the password" error
tx.success();
} catch (Exception ex) {
Log.logError("createNewGraphDB() Change Initial Password: " + ex.getLocalizedMessage());
} finally {tx.close(); graphDb.shutdown();}