Search code examples
javaneo4jneo4j-java-api

How to check if a Neo4j database existis at a given location


Calling

new GraphDatabaseFactory().newEmbeddedDatabase(File storeDir);

in the Neo4j Java API not only opens a database at a given location but also creates one if it doesn't already exist.

I would like to check if a Neo4j database exists in a given directory without creating one if it doesn't. How can I accomplish that?


Solution

  • I now do this by checking if there is a neostore file in the store directory and by trying to get it's version.

    See how you can get the store version here: Determine Neo4j database version