Database Reference
In-Depth Information
<dependencies>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>2.1.5</version>
</dependency>
</dependencies>
3. Next, create a Java class by the name
neo4j.embedded.myserver.EmbeddedServer.java and add follow-
ing piece of code:
public class EmbeddedServer {
private static void registerShutdownHook(final
GraphDatabaseService graphDb) {
// Registers a shutdown hook for the Neo4j.
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
//Shutdown the Database
System.out.println("Server is shutting down");
graphDb.shutdown();
}});
}
public static void main(String[] args) {
//Create a new Object of Graph Database
GraphDatabaseService graphDb = new
GraphDatabaseFactory().newEmbeddedDatabase("Location
of Storing Neo4j Database Files");
System.out.println("Server is up and Running");
//Register a Shutdown Hook
registerShutdownHook(graphDb);
}
}
And we are done!!! Now we can use the instance of graph database by the name
graphDb for creating nodes/relationships and properties.
Search WWH ::




Custom Search