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);
}
}
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)
please help
解决方案
Also there's no need to use ExecutionEngine. Just do a graphDb.execute(). Note this applies to Neo4j >= 2.3.