如何使用 Java 连接到本地安装的 neo4j 服务器 [英] How to connect to a locally installed neo4j server using Java

查看:31
本文介绍了如何使用 Java 连接到本地安装的 neo4j 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Neo4J 的新手,尽管我在谷歌上搜索了几个小时,但还是找不到我的问题的答案.

I'm new to Neo4J and couldn't find the answer to my question despite my hours of googling.

到目前为止,我一直在学习教程,现在我对如何/何时使用 Neo4j 有了基本的了解.现在,我将开始修改我的 hello-world 代码并连接到本地安装在我的机器上的 Neo4J 服务器,可通过 http 访问://127.0.0.1:7474.

So far, I have been following the tutorials and now I have a basic understanding of how/when to use Neo4j. Now, I am about to start modifying my hello-world code and connect to a Neo4J server locally installed on my machine, accessible via http://127.0.0.1:7474.

原始连接(使用嵌入式数据库):

Original connection (using an embedded database):

GraphDatabaseService gdb = new EmbeddedGraphDatabase("c:\helloworld\data\graph.db");

问题是无论如何修改这一行以连接到我在 c: eo4jdatagraph.db 中的服务器"数据库?该服务器当前作为 Windows 服务运行,我可以使用 Web 管理工具查看其数据库.目前,我对使用 REST API 不感兴趣,因为服务器和客户端应用程序在同一台机器上运行.

The question is is there anyway to modify this line to connect to my "server" database in c: eo4jdatagraph.db instead? The server is running currently as a windows service and I can view its database using the web admin tool. At this time, I am not interested in using the REST API since the server and the client app are running on the same machine.

我觉得我在这里遗漏了一些明显的东西......

I feel like I'm missing something obvious here...

推荐答案

windows 服务暴露了 REST 接口.

The windows service exposes the REST interface.

嵌入式接口完全不同 - 您将其指向数据库文件结构,然后通过 Java 方法调用访问它.

The embedded interface is entirely different - you point it at the database file structure and then access it via Java method calls.

如果两者同时运行,指向相同的数据,那么可能会发生不好的事情(实际上,我认为它会检测到并阻止它).因此,您可能需要停止服务和/或将此实例中的数据备份到另一个目录.然后编辑您的 EmbeddedGraphDatabase 构造函数以指向该目录.

If you have both running at the same time, pointing at the same data, then bad things might happen (actually, I think it detects this and prevents it). So you probably need to stop the service and/or backup the data from this instance to another directory. Then edit your EmbeddedGraphDatabase constructor to point to this directory.

手册 描述了嵌入式 Java 接口,就像您一样大概见过另请参阅本部分,其中简要介绍了相当不错的基于 Web 的管理界面.

The manual describes the embedded Java interface, as you've probably seen. See also this section which briefly mentions the rather nice web-based management interface.

这篇关于如何使用 Java 连接到本地安装的 neo4j 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆