neo4j / neo4j-jdbc

Official Neo4j JDBC Driver

Home Page:http://neo4j.github.io/neo4j-jdbc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PreparedStatement issue with jdbc driver 4 with neo4j 4

pratikm23 opened this issue · comments

Hi ,
I understand that neo4j 4.x now does not support params with such syntax - {1} and now supports $param. Has the syntax to execute preparedStatement also changed. What I mean by this is - when i try to execute query such as :

  String query = "MATCH (u:User)-[:FRIEND]-(f:User) WHERE u.name = {1} RETURN f.name, f.age";
    try (PreparedStatement stmt = con.prepareStatement(query)) {
        stmt.setString(1,"John");

        try (ResultSet rs = stmt.executeQuery()) {
            while (rs.next()) {
                System.out.println("Friend: "+rs.getString("f.name")+" is "+rs.getInt("f.age"));
            }
        }
    }

I get this error - ParameterIndex does not correspond to a parameter marker in the SQL statement

Hence is the syntax of {1} in prepared statement query with newer version of neo4j 4.2.3 and jdbc driver 4.0.1 still valid or are there any changes needed? If otherwise then could you also suggest what could be the error here.
Thanks in advance !

Can you try with $1 instead of {1}?

I had the same issues.
I tried with $1 and it worked but I'm working with a software which uses "{1}" and I cannot change that. I only have issues with that version of the Neo4j jdbc driver.

@baptistegh can you provide more details about your setup?

{param} will not work with 4.x Neo4j servers, only $param will.

You either have to:

  1. downgrade the JDBC driver and Neo4j server
  2. or upgrade the software responsible for creating the Cypher queries.

If you choose option 1, please be aware that only 3.5 is supported in the 3.x series, and it will reach end of life soon.

Closing this as we have not heard back.