Pavel Niedoba
Pavel Niedoba

Reputation: 1577

Neo4j client-server API

What is the way to use Java API in client-server setup of Neo4j?

Do I miss some kind of Java connector ? Only thing I found so far was REST api:http://neo4j.com/docs/stable/server-java-rest-client-example.html, but I have no idea how to use objects like:

org.neo4j.graphdb.GraphDatabaseService;
org.neo4j.graphdb.Label;
org.neo4j.graphdb.Node;
org.neo4j.graphdb.Transaction;
org.neo4j.graphdb.factory.GraphDatabaseFactory;
org.neo4j.graphdb.factory.GraphDatabaseSettings;
org.neo4j.graphdb.schema.ConstraintDefinition;
org.neo4j.graphdb.schema.ConstraintType;    

over REST. I want to avoid constructing cumbersome URLs and parse string responses. I want to migrate from my application from embedded to client-server, but so far it seems to impossible.

Upvotes: 0

Views: 606

Answers (2)

Pavel Niedoba
Pavel Niedoba

Reputation: 1577

I think FrobberOfBits answered this one right. Theres no Java API for client-server.

Upvotes: 0

Michael Hunger
Michael Hunger

Reputation: 41706

Actually there is a JDBC connector for Neo4j, check out:

http://neo4j.com/developer/java/#_using_neo4j_server_with_jdbc

And:

https://github.com/neo4j-contrib/neo4j-jdbc#minimum-viable-snippet

// Make sure Neo4j Driver is registered
Class.forName("org.neo4j.jdbc.Driver");

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

// Querying
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"));
    }
}

Upvotes: 2

Related Questions