cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Embedded Neo4j graph for existing database in Java

Hi,
I have updated my database to version 4.0.0, and I need to use it embedded, in Java. I updated the code so that I use the DatabaseManagementServiceBuilder. The directory I give to the builder constructor is the NEO4J_HOME, and when I create the GraphDatabaseService object, I provide the name of the database, as it appears in NEO4J_HOME/data/databases. However I get the error of not found database. I tried starting the database first by calling the startDatabase method, but that returns an error of "unsupported administration command: START DATABASE". I can't find online any embedded database example that does not delete the content of the dbms first and start with the population of an empty database.
Am I missing something? Is this the expected behavior? Of course, I can provide more details from logs and the java code if needed.

Thanks a lot,
Ioana

1 ACCEPTED SOLUTION

Multi-Database is a enterprise-only feature. I guess you do not have the respective enterprise jars on your classpath so startDatabase barks.
Not 100% sure, but in community the default database should be automatically started and you can get a reference to it via https://neo4j.com/docs/java-reference/4.0/javadocs/org/neo4j/dbms/api/DatabaseManagementService.html...

View solution in original post

3 REPLIES 3

Multi-Database is a enterprise-only feature. I guess you do not have the respective enterprise jars on your classpath so startDatabase barks.
Not 100% sure, but in community the default database should be automatically started and you can get a reference to it via https://neo4j.com/docs/java-reference/4.0/javadocs/org/neo4j/dbms/api/DatabaseManagementService.html...

Yes, I am using community edition.
Oh dear. So, indeed, calling setConfig(GraphDatabaseSettings.default_database, "nameofdb") and then creating GraphDatabaseService db = managementService.database("nameofdb"), started the database and now I can work with it.
I thought that providing the path to the NEO4J_HOME would ensure that the system uses the config file (where the default was set to the correct db) but seems like all settings must be set explicitly when building the DatabaseManagementService. But the fact that no other database can be accessed than the default, is a bit unexpected.
Thanks a lot for the quick and correct answer:)
-Ioana

.. and thanks for validating my theory 😉