Mary
Mary

Reputation: 69

Load neo4j database with java

I have a neo4j database ready and I want to make a java app for retrieving data from it. How can I load this already made database in my program and then query it? In the code I'm giving below I want to initialize the db object with that database.

thanks in advance

ExecutionEngine engine = new ExecutionEngine(db); String query = ""; ExecutionResult result = engine.execute( query);

Upvotes: 0

Views: 921

Answers (1)

Michael Hunger
Michael Hunger

Reputation: 41706

See the Tutorial in the Neo4j Manual:

http://docs.neo4j.org/chunked/stable/tutorials-cypher-java.html

GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase( DB_PATH );
ExecutionEngine engine = new ExecutionEngine( db );
ExecutionResult result = engine.execute( "start n=node(*) where n.name! = 'my node' return n, n.name" );

Make sure to keep the db and execution engine in a shared variable. And to shutdown() the db when your program ends.

Upvotes: 1

Related Questions