我在 Neo4j 数据库上使用 Gremlin。我能够加载 tinkergraph 数据库并对其进行 gremlin 遍历,但无法加载本地数据库并对其进行遍历。
从控制台上的修补程序图中,我使用以下命令,它工作正常:
g = new TinkerGraph();
g.loadGraphXML('/db/data/graph-example-1.xml');
g.V.name this works fine and getting the expected results.
即使从 Java 代码我也能做到。我发送相同的命令:
final String scriptURI = SERVER_ROOT_URI + "ext/GremlinPlugin/graphdb/execute_script";
WebResource resource = Client.create().resource(scriptURI);
String entity = toJsonNameValuePairCollection("script", " g = new TinkerGraph();g.loadGraphXML('/db/data/graph-example-1.xml');g.V.name");
ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).entity(entity .post(ClientResponse.class);
但是当我尝试从我在“db/data/”创建的硬盘访问数据时,它在控制台中工作正常,但不能通过 java 代码。
控制台命令:
g = new Neo4jGraph('db/data/'); 名称
我得到了预期的输出。
但是通过 Java 代码我收到以下错误: javax.script.ScriptException: java.lang.RuntimeException: java.io.FileNotFoundException
我的Java代码是:
最终字符串 scriptURI = SERVER_ROOT_URI + "ext/GremlinPlugin/graphdb/execute_script"; WebResource 资源 = Client.create().resource(scriptURI); String entity = toJsonNameValuePairCollection("script", "g = new Neo4jGraph('db/data/');gVname"); ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).entity(entity.post(ClientResponse.class);