Query a remote neo4j server via Java -


can provide example code of how connect , query remote neo4j server via java? i'm not looking embedded neo4j server implementation.

here attempt working:

import org.neo4j.cypher.javacompat.executionengine; import org.neo4j.cypher.javacompat.executionresult; import org.neo4j.graphdb.graphdatabaseservice; import org.neo4j.rest.graphdb.restgraphdatabase;  public static void main(string[] args) {         graphdatabaseservice neo4j = new restgraphdatabase("neo4jurl");         executionengine engine = new executionengine(neo4j);         string mycypher = "match n n.symptom = 'xanthelasma'";         executionresult result = engine.execute(mycypher);         system.out.println(result.tostring());     } 

this results in this:

exception in thread "main" java.lang.noclassdeffounderror: com/sun/jersey/api/client/filter/clientfilter     @ org.neo4j.rest.graphdb.executingrestapi.createrestrequest(executingrestapi.java:82)     @ org.neo4j.rest.graphdb.executingrestapi.<init>(executingrestapi.java:73)     @ org.neo4j.rest.graphdb.restapifacade.<init>(restapifacade.java:294)     @ org.neo4j.rest.graphdb.restgraphdatabase.<init>(restgraphdatabase.java:51)     @ mapreduce.networkanalysis.main(networkanalysis.java:20) caused by: java.lang.classnotfoundexception: com.sun.jersey.api.client.filter.clientfilter     @ java.net.urlclassloader$1.run(urlclassloader.java:366)     @ java.net.urlclassloader$1.run(urlclassloader.java:355)     @ java.security.accesscontroller.doprivileged(native method)     @ java.net.urlclassloader.findclass(urlclassloader.java:354)     @ java.lang.classloader.loadclass(classloader.java:425)     @ sun.misc.launcher$appclassloader.loadclass(launcher.java:308)     @ java.lang.classloader.loadclass(classloader.java:358)     ... 5 more 

i have tried implement using jersey:

string baseuri = new string("neo4jurl"); string payload = "db/data/node/5/relationships/all/co_sym"; client client = clientbuilder.newclient(); webtarget target = client.target(baseuri + payload); system.out.println(target.geturi()); invocation.builder invocationbuilder = target.request(); response response = invocationbuilder.get(); system.out.println(response.getstatus()); system.out.println(response.readentity(string.class)); 

this return data neo4j, in html format , utilize cypher query language.

don't that!

use

cypherqueryengine cypher = new restcypherqueryengine(restgraphdb.getrestapi()); cypher.query(statement, params); 

for second example, base-uri wrong. have add content-type , accept headers application/json


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -