gpt4 book ai didi

java - 执行 Neo4j Cypher 查询(通过 Java)嵌入式模式时出错

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:38:16 24 4
gpt4 key购买 nike

我在 java 中执行 Cypher 查询时出错(嵌入式模式)这是我的代码:

    import org.neo4j.cypher.internal.ExecutionEngine;
import org.neo4j.cypher.internal.ExecutionResult;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
public class test {
public static void main(String[] args) {
GraphDatabaseFactory graphdbFactory = new GraphDatabaseFactory();
GraphDatabaseService graphdb = new graphdbFactory.newEmbeddedDatabase("C:/Users/dell/Documents/Neo4j");
ExecutionEngine execEngine = new ExecutionEngine(graphDb);
ExecutionResult execResult = execEngine.execute
("MATCH (java:JAVA) RETURN java");
String results = execResult.dumpToString();
System.out.println(results);
}

}

我在该行收到错误:GraphDatabaseService graphdb = new graphdbFactory.newEmbeddedDatabase("C:/Users/dell/Documents/Neo4j");错误:类型图数据库工厂中的新嵌入式数据库(文件)方法不适用于参数(字符串)

请帮忙

最佳答案

GraphDatabaseFactory.newEmbeddedDatabase()期望一个 File而不是 String , 请参阅 http://neo4j.com/docs/java-reference/current/javadocs/org/neo4j/graphdb/factory/GraphDatabaseFactory.html#newEmbeddedDatabase-java.io.File-

也没有必要使用 ExecutionEngine .只需做一个 graphDb.execute(<cypherString>) .请注意,这适用于 Neo4j >= 2.3。

关于java - 执行 Neo4j Cypher 查询(通过 Java)嵌入式模式时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37875024/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com