执行Neo4j Cypher Query(通过Java)嵌入式模式时出错 [英] Error in Executing Neo4j Cypher Query (by Java) embedded mode
问题描述
我在用Java(嵌入式模式)执行Cypher查询时出错 这是我的代码:
Im having error in executing Cypher query in java (embedded mode) This is my code:
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"); 错误:类型图数据库工厂中的新嵌入式数据库(文件)方法不适用于参数(字符串)
Im getting error at the line : GraphDatabaseService graphdb = new graphdbFactory.newEmbeddedDatabase("C:/Users/dell/Documents/Neo4j"); error: the method new embedded database (file) in the type graph database factory is not applicable for the arguments (string)
请帮助
推荐答案
GraphDatabaseFactory.newEmbeddedDatabase()
需要File
而不是String
,请参见
GraphDatabaseFactory.newEmbeddedDatabase()
expects a File
and not a String
, see 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.
Also there's no need to use ExecutionEngine
. Just do a graphDb.execute(<cypherString>)
. Note this applies to Neo4j >= 2.3.
这篇关于执行Neo4j Cypher Query(通过Java)嵌入式模式时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!