Search code examples
javaneo4jbolt

How can I connect to Neo4J embedded instance using reactive driver?


So far, I have been using this code to connect to embedded Neo4J instance:

DatabaseManagementService managementService = new DatabaseManagementServiceBuilder(new File("neo")).build();
GraphDatabaseService graphDb = managementService.database(DEFAULT_DATABASE_NAME);

(using this)

Now, I'm switching to Neo4J driver. But I don't know how to make the connection to embedded database. I tried this:

Driver driver = GraphDatabase.driver("bolt://localhost:7687");

but obviously is not working because there is no Neo4J server running, but just a database file. I guess I need to run bolt server first, exposing neo dir, that is where my database resides. How can I do this?


Solution

  • After diving into the code, I found out that this code:

    DatabaseManagementService managementService = new DatabaseManagementServiceBuilder(new File("neo")).build();
    

    actually starts a bolt server. So I did this:

    DatabaseManagementService managementService = new DatabaseManagementServiceBuilder(new File("neo")).build();
    Driver driver = GraphDatabase.driver("bolt://localhost:7687");
    

    and everything started working.