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

查看:773
本文介绍了如何使用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中的服务器数据库: \ neo4j\data\graph.db而不是?服务器当前正在作为Windows服务运行,我可以使用Web管理工具查看其数据库。目前,我对使用REST API不感兴趣,因为服务器和客户端应用程序在同一台机器上运行。

The question is is there anyway to modify this line to connect to my "server" database in c:\neo4j\data\graph.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天全站免登陆