试图构建一个用于访问 Neo4j 数据的 Java 客户端,我不想使用 Neo4j 的嵌入式模式,请有人给我相同的示例代码,我正在尝试运行以下代码
import org.neo4j.rest.graphdb.RestAPI;
import org.neo4j.rest.graphdb.RestAPIFacade;
import org.neo4j.rest.graphdb.RestGraphDatabase;
import org.neo4j.rest.graphdb.query.RestCypherQueryEngine;
import org.neo4j.rest.graphdb.util.QueryResult;
import static org.neo4j.helpers.collection.MapUtil.map;
import java.util.Map;
public class CypherQuery {
public static void main(String[] args) {
try{
System.out.println("starting test");
final RestAPI api = new RestAPIFacade("http://localhost:7474/db/data/");
System.out.println("API created");
final RestCypherQueryEngine engine = new RestCypherQueryEngine(api);
System.out.println("engine created");
final QueryResult<Map<String,Object>> result = engine.query("start n=node(2) return n, n.name as name;", map("id", 0));
System.out.println("query created");
for (Map<String, Object> row : result) {
long id=((Number)row.get("id")).longValue();
System.out.println("id is " + id);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
但它没有显示任何错误或异常,也没有产生任何输出。