java - Run a Cypher query from Spring to Neo4j -
i have uploaded csv file , have nodes , relationship defined on neo4j. i've tried create program base on example run cypher query spring generate output neo4j. however, i'm encountering error:
exception in thread "main" java.lang.nosuchmethoderror:org.neo4j.graphdb.factory.graphdatabasefactory.newembeddeddatabase(ljava/io/file;)lorg/neo4j/graphdb/graphdatabaseservice; @ org.neo4j.connection.neo4j.run(neo4j.java:43) @ org.neo4j.connection.neo4j.main(neo4j.java:37)
i'm wondering possibly error? here code:
public class neo4j{ public enum nodetype implements label{ issues, cost, reliability, timeliness; } public enum relationtype implements relationshiptype{ applies_to } string rows = ""; string noderesult; string resultstring; string columnstring; private static file db_path = new file("/users/phaml1/documents/neo4j/default.graphdb/import/"); public static void main(string[] args){ neo4j test = new neo4j(); test.run(); } void run() { clear(); graphdatabaseservice db = new graphdatabasefactory().newembeddeddatabase(db_path); try(transaction tx1 = db.begintx(); result result = db.execute("match(b:business)-[:applies_to]->(e:time) return b,e")) { while(result.hasnext()) { while ( result.hasnext() ) { map<string,object> row = result.next(); ( entry<string,object> column : row.entryset() ) { rows += column.getkey() + ": " + column.getvalue() + "; "; } rows += "\n"; } } try (transaction = db.begintx(); result result1 = db.execute("match(b:business)-[:applies_to]->(e:time) return b,e")) { iterator<node> n_column = result.columnas("n"); for(node node: iterators.asiterable(n_column)) { noderesult = node + ": " + node.getproperties("description"); } list<string> columns = result.columns(); columnstring = columns.tostring(); resultstring = db.execute("match(b:business)-[:applies_to]->(e:time) return b,e").resultasstring(); } db.shutdown(); } } private void clear(){ try{ deleterecursively(db_path); } catch(ioexception e){ throw new runtimeexception(e); } }
}
it looks neo4j version conflict.
graphdatabaseservice db = new graphdatabasefactory().newembeddeddatabase(db_path);
has string argument in neo4j 2x (https://neo4j.com/api_docs/2.0.3/org/neo4j/graphdb/factory/graphdatabasefactory.html#newembeddeddatabase(java.lang.string))
but file in neo4j 3x (http://neo4j.com/docs/java-reference/current/javadocs/org/neo4j/graphdb/factory/graphdatabasefactory.html#newembeddeddatabase-java.io.file-)
sdn pulling in neo4j 2.3.6 dependency- please check dependency tree , override neo4j version
Comments
Post a Comment