Я пытаюсь вставить данные в базу данных диаграммы neo4j. Я пытаюсь создать узел типа Person, чье имя «Thamali», используя jersey-клиент. Я дал код java, который я использую ниже. Я пытаюсь выполнить запрос cypher CREATE (thamali:Person {name:"Thamali"})
Используя приведенный ниже код Java.Исключение при выполнении запроса cypher с строкой из кода Java
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
import javax.ws.rs.core.MediaType;
public class NeoAPIClass {
private final String baseUri = "http://localhost:7474/db/data/cypher";
private final String user = "neo4j";
private final String password = "12345";
public static void main(String args[]){
NeoAPIClass n=new NeoAPIClass();
n.runQuery();
}
void runQuery(){
Client client = Client.create();
client.addFilter(new HTTPBasicAuthFilter(user, password));
WebResource cypherResource = client.resource(baseUri);
String s="{\"query\":\"CREATE (thamali:Person{name:\"Thamali\"})\"}";
ClientResponse cypherResponse = cypherResource.accept(MediaType.APPLICATION_JSON)
.type(MediaType.APPLICATION_JSON_TYPE).entity(s).post(ClientResponse.class);
System.out.println("Output from Server .... "+ cypherResponse.getStatus());
}
}
Я получаю следующее исключение с кодом состояния HTTP 500.
ERROR The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container Unexpected character ('T' (code 84)): was expecting comma to separate OBJECT entries [line: 1, column: 41]
org.neo4j.server.rest.repr.BadInputException: Unexpected character ('T' (code 84)): was expecting comma to separate OBJECT entries [line: 1, column: 41]
at org.neo4j.server.rest.repr.formats.JsonFormat.readMap(JsonFormat.java:94)
at org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
Caused by: org.neo4j.server.rest.domain.JsonParseException: Unexpected character ('T' (code 84)): was expecting comma to separate OBJECT entries [line: 1, column: 41]
at org.neo4j.server.rest.domain.JsonHelper.readJson(JsonHelper.java:73)
at org.neo4j.server.rest.domain.JsonHelper.jsonToMap(JsonHelper.java:54)
at org.neo4j.server.rest.repr.formats.JsonFormat.readMap(JsonFormat.java:90)
... 43 more
Может кто-нибудь, пожалуйста, помогите мне решить эту проблему.
Большое спасибо, и я мог бы решить свою проблему. Можете ли вы мне помочь и с этим. Мне нужно включить строковый параметр в запрос cypher http://stackoverflow.com/questions/41646451/error-in-interting-a-string-parameter-to-a-cypher-query-in-a-java-code/41647180 # 41647180 –