Java 使用Android连接Neo4J

Java 使用Android连接Neo4J,java,android,rest,jar,Java,Android,Rest,Jar,我正在尝试从Android应用程序连接到本地主机(Neo4J数据库) 实现这一点的方法是使用几个库: neo4J-rest-graphdb-1.8.1.jar neo4J-rest-graphdb-1.8.1-javadoc-.jar neo4J-rest-graphdb-1.8.1-sources.jar neo4J-rest-graphdb-1.8.1-test-sources.jar neo4J-rest-graphdb-1.8.1-tests.jar neo4j-server-1.8.

我正在尝试从Android应用程序连接到本地主机(Neo4J数据库)

实现这一点的方法是使用几个库:

  • neo4J-rest-graphdb-1.8.1.jar
  • neo4J-rest-graphdb-1.8.1-javadoc-.jar
  • neo4J-rest-graphdb-1.8.1-sources.jar
  • neo4J-rest-graphdb-1.8.1-test-sources.jar
  • neo4J-rest-graphdb-1.8.1-tests.jar
  • neo4j-server-1.8.M03.jar
当我将这些库添加到Java构建路径时,它可以使用它们连接到Neo4J数据库,如下所示:

    import org.neo4j.rest.graphdb.RestAPI;
    import org.neo4j.rest.graphdb.RestAPIFacade;
    import org.neo4j.rest.graphdb.query.QueryEngine;
    import org.neo4j.rest.graphdb.query.RestCypherQueryEngine;
    import org.neo4j.rest.graphdb.util.QueryResult;

    RestAPI graphDb = new RestAPIFacade("http://localhost:7474/db/data");

    QueryEngine engine=new RestCypherQueryEngine(graphDb);                  
    QueryResult<Map<String,Object>> result = engine.query("create (:Person {name:\"Steve\"}) return n", Collections.EMPTY_MAP); 
    Iterator<Map<String, Object>> iterator=result.iterator(); 

     if(iterator.hasNext()) {       
       Map<String,Object> row= iterator.next();            

       int duration = Toast.LENGTH_LONG;
        Toast toast = Toast.makeText(getApplicationContext(),"" + row.get("total") , duration);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();           
     }
import org.neo4j.rest.graphdb.RestAPI;
导入org.neo4j.rest.graphdb.RestAPIFacade;
导入org.neo4j.rest.graphdb.query.QueryEngine;
导入org.neo4j.rest.graphdb.query.RestCypherQueryEngine;
导入org.neo4j.rest.graphdb.util.QueryResult;
RestAPI graphDb=新的RestAPIFacade(“http://localhost:7474/db/data");
查询引擎=新的RestCypherQueryEngine(graphDb);
QueryResult result=engine.query(“创建(:Person{name:\'Steve\'})返回n”,Collections.EMPTY\u映射);
迭代器迭代器=result.Iterator();
if(iterator.hasNext()){
Map row=iterator.next();
int duration=Toast.LENGTH\u LONG;
Toast Toast=Toast.makeText(getApplicationContext(),“”+row.get(“总计”),持续时间);
toast.setGravity(Gravity.CENTER,0,0);
toast.show();
}
问题是我一直收到一个错误:NoClassDefFoundError org.neo4j.rest.graphdb.RestAPIFacade

我认为这是因为缺少构建路径的jar文件。。。但是我不确定。。也许是别的什么地方出了问题。我已经试着安装Maven。。但它不会通过市场安装,因为它说它缺少存储库

任何帮助都会很好

你应该看看这里

您无法使用“localhost”从Android Emulator连接到本地服务器。您需要使用此ip 10.0.2.2

RestAPI graphDb = new RestAPIFacade("http://10.0.2.2:7474/db/data");