Neo4j Embedded Mode with Password

630 Views Asked by At

Can you connect to Neo4j in embedded mode in a Java application to connect to an existing running Neo4J server that requires a username and password?

How do you do that? Apparently without authentication it is:

graphDb = new GraphDatabaseFactory().newEmbeddedDatabase( DB_PATH );
registerShutdownHook( graphDb );
1

There are 1 best solutions below

1
On BEST ANSWER

Http authentication is part of the Neo4j server component. The code snippet that you're using runs an embedded database instance.

Please clarify your question if a) you want some code connecting to a running Neo4j remote instance or b) you want to run your own embedded instance and run the web interface on top of it?

In case of a) you can either work with the transactional Cypher endpoint, use Neo4j JDBC driver or (starting with Neo4j) the java bolt driver.

In case of b) you need to look at Neo4j's source code to understand what org.neo4j.server.Bootstrapper and its derived classes are doing. With those you can run your server on top of an embedded instance.