Reputation: 357
Playing around on my Neo4j
on my localhost, I constructed this query to toggle the node property 'Active' between 'true' and 'false'
I works fine when executed in the browser but when I put it in my java class using JDBC the result is none.
String query = "MATCH (i:Item) "
+ "WHERE id(i)=? "
+ "SET i.active = NOT i.active";
PreparedStatement ps = con.prepareStatement(query);
ps.setInt(1, id);
int updates = ps.executeUpdate();
Upvotes: 0
Views: 53
Reputation: 469
Your query should be changed as follows. You should define parameters in {}
String query = "MATCH (i:Item) "
+ "WHERE id(i)= {1} "
+ "SET i.active = NOT i.active";
Since you are not return anything you are getting return value as 0. executeUpdate() return either the row count for statement or 0 for statements that return nothing.
Upvotes: 1