Java Connection neo4j REST API

Source: Internet
Author: User
Tags neo4j

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.