-
Notifications
You must be signed in to change notification settings - Fork 463
Description
Hello there, I got some trouble in using JDBC preparestatement. So I want to share about my experiences.
I have been confused rather am I doing something wrong or is it a bug. So, I just write down those phenomena.
-
Querystring
-
PrepareStatement
PreparedStatement pstmt = connectionHelper.createConnection().prepareStatement( "select * from cypher('a', $$ "+ "match (a) where id(a) = ? return properties(a)" + "$$) as (a agtype););" pstmt.setString(1, "281474976710667"); //character '?' is replaced to 281474976710667
-
Prepared Statements Preparation & Execution in "Apache_AGE_Guide.pdf"
PreparedStatement pstmt = connectionHelper.createConnection().prepareStatement( "PREPARE cypher_stored_procedure(agtype) AS " + "select * " + "from cypher('a', $$ " + "match (a) " + "where a.id = $id " + "return properties(a) " + "$$, $1) as (a agtype);" + "EXECUTE cypher_stored_procedure(('{\"id\": \" ? \"}'))"); pstmt.setString(1, "844424930131976"); // character '?' is replaced to 844424930131976
-
-
Error message
Both of them got the same out of index error. because they aren't replaced to other strings which is what we want to replace. (org.postgresql.util.PSQLException: The column index is out of range: 1, number of columns: 0.)
-
Suggestion
I asked about these errors to a coworker and understood why those errors were thrown. Because of accurate error showing, you guys did so.
I concluded dollar-quoted strings are not to be replaced now. But JDBC standards compatibility is a kind of important thing about normal users. And AGE is an extension of Postgres. So how about some another route about preparestatement supporting?
-
Conclusion
I am waiting for your opinion. or maybe you want some specific things about this article. then, feel easy to tell me. I would happily append more detailed info. If I got something miss or wrong, just let me know.
Many thanks..