Reputation: 3
I directly made a neo4j dataset by using neo4j console ("localhost:7474") (as you knew "graph.db") I wanna execute Cypher Query (by Java) Using this data.
I already saw the example from
I just wanna use this way but directly use existing data.
How can I do this?
Upvotes: 0
Views: 4468
Reputation: 1200
I wrote this few months ago. It's very minimalist in order to be easy to understand ! https://github.com/bendaizer/neo4j_cypher_java_template
You just need to give the path to your database directory (with you data), and your cypher query. I didn't had time to write something better, so you need to recompile for each new query !
Upvotes: 0
Reputation: 19373
If you are using Neo4j in embedded mode i.e. it runs within the same jvm as your application, you can access it using:
GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(DBPATH)
where DBPATH is the path to the database you created using Webadmin. You can find that path in your neo4j install directory/conf/neo4j-server.properties (The property name is org.neo4j.server.database.location)
Once you have instantiated your graphDb, you can execute Cypher queries as described in http://docs.neo4j.org/chunked/stable/tutorials-cypher-java.html
If you are not using Neo4j in embedded mode and want to connect to the existing server running on port 7474, you can use the java rest binding: https://github.com/neo4j/java-rest-binding/
Upvotes: 1