0
votes

I am new to Neo4j and am reading this example:

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

In my Eclipse, this code works fine. However, I already have a Neo4j database which I can access through

http://localhost:7474/browser/

My question is in my Java code above, how can I access my existing Neo4j database? If I change "bolt://localhost:7687" to "http://localhost:7474", I received this error:

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)

So how can I access my existing database (http://localhost:7474) through 'bolt'?

1

1 Answers

0
votes

You can access a Neo4j database through 2 protocols :

  • HTTP/REST on default port 7474
  • BOLT on default port 7687

So on your example, you are trying to use a BOLT client on the HTTP, this can't work.

So the good url is the one into your java code : "bolt://localhost:7687"