Is it possible to have a Java program and a Rest client access a Neo4J database -



Is it possible to have a Java program and a Rest client access a Neo4J database -

it understanding if using java execution engine cannot have neo4j process allows access db through web console. same process facilitates rest api, correct? there way utilize execution engine through java programme , rest api?

so main issue understand 1 jvm process can access database @ time. when talk rest api, mean there neo4j server running. jvm process has locked database. , server instance happens provide rest api on host , port. now, if you've got server instance running, can't separately run different java process accesses same database using embedded database.

to want, have 2 options:

option 1: utilize rest java

you can write java programme uses rest interface. in case, sec java programme making network calls server, , not touching database straight itself. no conflict, can both.

your code different - more focused on issuing restful calls , processing resulting json, this:

final string txuri = server_root_uri + "transaction/commit"; webresource resource = client.create().resource( txuri ); string payload = "{\"statements\" : [ {\"statement\" : \"" +query + "\"} ]}"; clientresponse response = resource .accept( mediatype.application_json ) .type( mediatype.application_json ) .entity( payload ) .post( clientresponse.class ); system.out.println( string.format( "post [%s] [%s], status code [%d], returned data: " + system.getproperty( "line.separator" ) + "%s", payload, txuri, response.getstatus(), response.getentity( string.class ) ) ); response.close();

see before links more code examples , tutorials.

option 2: utilize graphdatabaseservice wrapper

there's graphdatabaseservice wrapper. lets this:

graphdatabaseservice gds = new restgraphdatabase("http://localhost:7474/db/data");

you can utilize gds object much utilize regular java api object.

this works same reason alternative 1 - you're not hitting database directly, interacting restful services through wrapper.

neo4j

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -