fereshteh
fereshteh

Reputation: 539

How to create a neo4j graph database within a java application

I want to write a java application which gets the values and information from user and creates the graph database with neo4j,my question:

how should I create a neo4j graph database within my java application?

what tools should I use?

I read neo4j tutorials,but they were about creating a database first and query it from the application.

Thanks in advance.

Upvotes: 0

Views: 2160

Answers (2)

5agado
5agado

Reputation: 2454

If you want to use the Neo4j library in your project I would suggest to first add the relative Maven dependency. Then, for the creation of a new database, just use this line:

GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH)

If the database doesn't already exists, it will be created. Finally you should call

db.shutdown()

The manual suggests to register a shutdown hook in order to be sure to have a right shutdown of the database

Upvotes: 0

Luanne
Luanne

Reputation: 19373

If you are using Embedded neo4j, please see http://docs.neo4j.org/chunked/milestone/tutorials-java-embedded.html Otherwise take a look at http://docs.neo4j.org/chunked/milestone/tutorials-rest.html and/or http://www.neo4j.org/develop/drivers if you wish to use things such as Spring Data

Upvotes: 2

Related Questions