title: Clear Neo4j Embedded database
body: <p>With a new version of Spring Data Neo4j I can't use Neo4jHelper.cleanDb(db);</p>
  
  <p>So, what is the most effective way to completly clear Embedded Neo4j database in my application?</p>
  
  <p>I have implemented my own util method for this purpose, but this method is slow:</p>
  
  <pre><code>public static void cleanDb(Neo4jTemplate template) {
      template.query("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r", null);
  }
  </code></pre>
  
  <p>How to properly clear/delete database ?</p>
  
  <p><strong>UPDATED</strong></p>
  
  <p>This is the similar question <a href="https://stackoverflow.com/questions/23310114/how-to-reset-neo4j-database">How to reset / clear / delete neo4j database?</a> but I don't know how to programmatically shutdown Embedded Neo4j and how to start it after deleting.</p>
  
  <p>I use Spring Data Neo4j and based on the user request I'd like to clear/delete existing database and recreate it with a new data. How to start up new embedded database after suggested invocation of shutdown method ?</p>
  
  <p><strong>USE CASE:</strong></p>
  
  <p>On the working application I have configured embedded database:</p>
  
  <pre><code>GraphDatabaseService graphDb = new GraphDatabaseFactory()
                  .newEmbeddedDatabaseBuilder(environment.getProperty(NEO4J_EMBEDDED_DATABASE_PATH_PROPERTY))
                  .setConfig(GraphDatabaseSettings.node_keys_indexable, "name,description")
                  .setConfig(GraphDatabaseSettings.node_auto_indexing, "true")
                  .newGraphDatabase();
  </code></pre>
  
  <p>Also, I pre populate this database with 1000000 nodes. On the user request I need to clear this database and populate it with a new data. How to correctly and quick clear existing database ?</p>
  
  <p>Can I call Neo4j database API for new node creation after <code>database.shutdown()</code> or do I need to initialize new database before it?</p>