【问题标题】:How to use bolt protocol to access my Neo4j Database?如何使用 bolt 协议访问我的 Neo4j 数据库?
【发布时间】:2018-02-04 04:44:15
【问题描述】:

我是 Neo4j 的新手,正在阅读这个示例:

try ( HelloWorldExample greeter = new HelloWorldExample( "bolt://localhost:7687", "neo4j", "test" ) )
        {
            greeter.printGreeting( "hello, world" );
        }

在我的 Eclipse 中,这段代码运行良好。但是,我已经有一个可以通过

访问的 Neo4j 数据库
http://localhost:7474/browser/

我的问题是在我上面的 Java 代码中,如何访问我现有的 Neo4j 数据库?如果我将“bolt://localhost:7687”更改为“http://localhost:7474”,我会收到此错误:

Exception in thread "main" org.neo4j.driver.v1.exceptions.ClientException: Unsupported URI scheme: http
    at org.neo4j.driver.internal.DriverFactory.createDriver(DriverFactory.java:125)
    at org.neo4j.driver.internal.DriverFactory.newInstance(DriverFactory.java:82)
    at org.neo4j.driver.v1.GraphDatabase.driver(GraphDatabase.java:136)
    at org.neo4j.driver.v1.GraphDatabase.driver(GraphDatabase.java:119)
    at org.neo4j.driver.v1.GraphDatabase.driver(GraphDatabase.java:94)
    at neo4j.Neo4j.<init>(Neo4j.java:19)
    at neo4j.Neo4j.main(Neo4j.java:50)

那么我怎样才能通过'bolt'访问我现有的数据库(http://localhost:7474)?

【问题讨论】:

    标签: neo4j


    【解决方案1】:

    您可以通过 2 个协议访问 Neo4j 数据库:

    • 默认端口7474上的HTTP/REST
    • 默认端口7687上的BOLT

    因此,在您的示例中,您尝试在 HTTP 上使用 BOLT 客户端,这是行不通的。

    所以好的 url 是你的 java 代码中的一个:"bolt://localhost:7687"

    【讨论】:

    • 是的,这是真的。但我的问题是关于如何使用螺栓协议来访问我现有的数据库。比如我现有的数据库可以通过192.168.194.3:7474/browser浏览,它在另一台电脑上。螺栓://192.168.194.3:7687 不起作用。
    • 默认情况下,Neo4j 只监听本地,而不是网络。您必须在 neo4j.conf 文件中取消注释此行:dbms.connectors.default_listen_address=0.0.0.0
    • 很高兴知道。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多