我有一个用于连接 neo4j 的 java 程序。想要将参数传递给密码查询,该参数是用户给定的变量值。
void connect() {
graphDataService = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);
Transaction transaction = graphDataService.beginTx();
String name = "";
Scanner sc_name = new Scanner(System.in);
System.out.println("enter name : ");
name=sc_name.next();
try {
ExecutionEngine engine = new ExecutionEngine(graphDataService);
ExecutionResult result = engine.execute("START n = node(*) where n.nodename = ? return n");
System.out.println(result.dumpToString());
transaction.success();
}
finally {
transaction.finish();
}
}
我应该如何连接将替换的变量名中的值?并获取结果。任何想法?