简体   繁体   English

使用IP地址通过Java Neo4j API连接Neo4j服务器

[英]Connect neo4j server through java neo4j api using ip address

I am using java neo4j api for connecting to neo4j and perform operation on it using. 我正在使用java neo4j api连接到neo4j并使用对其执行操作。

GraphDatabaseFactory gdf=new GraphDatabaseFactory(); GraphDatabaseFactory gdf ​​= new GraphDatabaseFactory();
GraphDatabaseService gds = gdf.newEmbeddedDatabase(new File(" path for neo4j databases /graph.db")); GraphDatabaseService gds = gdf.newEmbeddedDatabase(new File(“ neo4j数据库的路径 /graph.db”));

I am able to do all kind of operation but now i want to connect through IP address ie instead of filepath i want to connect neo4j on different network but i am unable to see any option regarding this. 我能够进行所有类型的操作,但是现在我想通过IP地址进行连接,即要代替文件路径,我想在不同的网络上连接neo4j,但是我看不到任何关于此的选项。

Every search reult shows use of graphdatabase and driver for connecting to network but for that exection query format is changed ie i have to write in cypher language. 每个搜索结果都显示使用graphdatabase和驱动程序来连接网络,但是对于该执行查询格式已更改,即我必须用密码语言编写。 But I have already written a code which is working fine in my system using GraphDatabaseService object and org.neo4j.graphdb ie neo4j java rest api. 但是我已经使用GraphDatabaseService对象和org.neo4j.graphdb(即neo4j java rest api)编写了可以在我的系统中正常工作的代码。

Any how can I connect to ip address through GraphDatabaseService. 我该如何通过GraphDatabaseService连接到IP地址。 If no then how can i connect such that in the end, i get GraphDatabaseService object as I have written complete code for my project and there is no time to change it. 如果没有,那么我该如何连接,最后得到GraphDatabaseService对象,因为我已经为我的项目编写了完整的代码,没有时间进行更改。

I have already hosted neo4j server on another network and enabled all the listening port. 我已经在另一个网络上托管了neo4j服务器,并启用了所有侦听端口。

With GraphDatabaseFactory you can only create an embedded database. 使用GraphDatabaseFactory您只能创建一个嵌入式数据库。 Because it's an embedded mode, you have access to the JAVA API of Neo4j, but this one can only used on the server side ... not remotely. 因为它是一种嵌入式模式,所以您可以访问Neo4j的JAVA API,但是该模式只能在服务器端使用,不能远程使用。

If you want to connect to a remote database, you should use the java bolt driver, and so to rewrite your query in Cypher (it's the good way to do now). 如果要连接到远程数据库,则应使用java螺栓驱动程序,以便在Cypher中重写查询(这是现在的好方法)。

If you have some use-cases that really need the Neo4j Java API (like the traversal API), you can create a Cypher procedures, and call it in a cypher query. 如果您有一些确实需要Neo4j Java API(例如遍历API)的用例,则可以创建一个Cypher过程,并在cypher查询中调用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM