我有错误执行Cypher查询在java(嵌入式模式)这是我的代码:
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);
}
}
我在该行收到错误:GraphDatabase aseService graph db=new graph dbFactory. newEmbeddedDatabase("C:/User/dell/Documents/Neo4j");错误:类型图数据库工厂中的新嵌入式数据库(文件)方法不适用于参数(字符串)
请帮忙
GraphDatabase aseFactory. newEmbeddedDatabase()
需要File
而不是String
,请参见http://neo4j.com/docs/java-reference/current/javadocs/org/neo4j/graphdb/factory/GraphDatabaseFactory.html#newEmbeddedDatabase-java.io.File-
也不需要使用ExecutionEngine
。只需执行graph Db.执行(
下面的代码应该可以解决这个问题。
File store File=new File("C:/用户/戴尔/文档/Neo4j");
GraphDatabase aseService db=dbFactory. newEmbeddedDatabase(存储文件);