resultset is not matching when executing cypher in neo4j-jdbc

134 Views Asked by At

I want to execute cypher statment using neo4j-jdbc jar remotely.

When I execute the below cypher, I am getting resultset with 25 rows in neo4j web console.

 MATCH (n:USER) RETURN n LIMIT 25

When I execute the same program using the neo4j-jdbc remotely, I am getting 0 results.

 public static void main(String[] args) throws Exception {
     Neo4jConnection connect = (Neo4jConnection) DriverManager.getConnection("jdbc:neo4j://localhost:7474","neo4j","Neo4J");
     final PreparedStatement statement = connect.prepareStatement("MATCH (n:USER) RETURN n LIMIT 25");
     final ResultSet result = statement.executeQuery();

     System.out.println(result.getFetchSize());
     result.close();
     statement.close();
     connect.close();
}

It is printing size as zero.

I am not sure, what is the mistake exactly.

1

There are 1 best solutions below

0
On

I don't think ResultSet.getFetchSize returns the number of rows returned from the query. I believe it instead relates to the number of rows that should be returned in each roundtrip to the database.

To check for results from the query try to iterate through result and print each row:

ResultSet result = statement.executeQuery();
while (result.next()) { 
    System.out.println(result.getString("n"));
}