NEO4J connection Java currently has embedded, JDBC, and rest APIs.
JDBC: The Lib package to use: Neo4j-jdbc-2.0.1-snapshot-jar-with-dependencies.jar
Connection con =DriverManager. getconnection ("jdbc:neo4j://localhost:7474/");//Create a connectionString Query= "Start N = node ({1}) return N.name"; PreparedStatement stmt=NULL;//with precompilation, unlike relational databases, parameters need to use {1},{2} instead of?ResultSet rs =NULL; Try{stmt=con.preparestatement (query); Stmt.setint (1, 14); RS=Stmt.executequery (); System.out.println (Rs.getrow ()); while(Rs.next ()) {System.out.println ("A" + rs.getstring ("N.name"))); } } Catch(Exception e) {Throwe; } finally { if(NULL!=RS) {Rs.close (); } if(NULL!=stmt) {Stmt.close (); } }
The JDBC connection is a serviced neo4j.
At present, the Shorestpath method provided by Cypher language only supports calculating the path with the smallest number of nodes between two nodes, does not support the calculation of weights between relationships, and if the shortest path to calculate weights needs to be computed, it needs to use inline, or service-based rest API.
Java Connection neo4j JDBC