3

I am a newbie to neo4j serve. I started working on neo4j server through direct cypher queries on neo4j local server queries of creating node, label, node properties, relationship between nodes etc.. I have little bit ideas on how are things working.

Problem that I am facing is that I have stucked in connecting with neo4j server using java.

Codes I am currently trying to use to connect with local server are:-

GraphDatabaseService db = new RestGraphDatabase("http://localhost:7474/db/data");

RestGraphDatabase graphDb = new RestGraphDatabase("http://localhost:7474/db/data");

But every time I get the error 500 Server Error The call failed on the server; see server log for details

Unable to find out the reason. I am perfectly connected to my local server.But still problem remains the same.

I have succeeded in connecting with server and doing basic operation using rest api. But Still finding difficult for searching in it.That is why wanted help in using the neo4j jar files for the functionality of neo4j graph db.

Links I am following:-RestApi

Embedded graphDb

RestServer

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
Vartika
  • 1,085
  • 3
  • 17
  • 43

2 Answers2

1

I recommend to check out the JDBC driver.

See http://neo4j.com/developer/java

Michael Hunger
  • 41,339
  • 3
  • 57
  • 80
0

You need to add the jar file that helps you in connecting with neo4j server. You can find the driver/jar file from https://github.com/larusba/doc2graph/releases/tag/v1.0.0

After downloading the file add it to your project using project preferences. Then, go using the below code to starting working on it!

Connection con = DriverManager.getConnection("jdbc:neo4j:bolt://localhost");

    try (Statement stmt = con.createStatement()) {
        ResultSet rs = stmt.executeQuery("MATCH (n:User) RETURN n.name");
        while (rs.next()) {
            System.out.println(rs.getString("n.name"));
        }
    }
    con.close();
  • Welcome to Stack Overflow. While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value. [How to Answer](https://stackoverflow.com/help/how-to-answer). Regards. – Elletlar Dec 27 '18 at 13:12
  • @Elletlar I have updated my answer. Thanks for the suggesstion – Shahzad Ahmed Jan 03 '19 at 11:34