NEO4J connection Java currently has embedded, JDBC, and rest APIs.
Take the neo4j document Jersey as an example (there are many ways to achieve, currently feel jersey implementation is more troublesome, others have encapsulated good request).
LIB Package used: Jersey-bundle-1.17.jar (this is not easy to find) and Jersey provided package
String Server_root_uri = "http://localhost:7474/db/data/"; FinalString Nodeentrypointuri = Server_root_uri + "Node"; WebResource Resource=client.create (). resource (Nodeentrypointuri); //POST {} to the node entry point URI//Create a new node with a POST requestClientresponse response =resource.accept (Mediatype.application_json). Type (Mediatype.application_json). Enti Ty ("{}"). Post (clientresponse.class ); FinalURI location =response.getlocation (); System.out.println (String.Format ("POST to [%s], status code [%d], location header [%s]", Nodeentrypointuri, Response.getstatus (), location.tostring ())); Response.close (); System.out.println (Location.tostring ()); String Propertyuri= location.tostring () + "/properties/" + "name"; // http://localhost: 7474/db/data/node/{node_id}/properties/{property_name}WebResource Propertyresource=client.create (). resource (Propertyuri); //set the properties of the node based on the node URL that was taken backClientresponse response1 =propertyresource.accept (Mediatype.application_json). Type (Mediatype.application_json) . Entity ("\" Joe strummer\ ""). Put (Clientresponse.class ); System.out.println (String.Format ("PUT to [%s], status code [%d]", Propertyuri, Response1.getstatus ())); Response.close ();
Jersey this way personal feel is not very good to use, when creating a node can not be added to the attribute, must be {}, and then in accordance with the node URL to add attributes, more cumbersome, but based on the weight of the shortest path, if you want to use the service-style neo4j.
Java Connection neo4j REST API