Reputation: 685
How can I use this cypher query using APOC in Java program?
CALL apoc.export.csv.query("match (m:Movie) where m.name='Matrix'
RETURN m.name","results.csv",{})
If any one can refer/suggest to sample JAVA code, it would be great. A few lines or one line code, I shall a thankful.
Following is my Sample code which is giving error at line:
StatementResult result = session.run("CALL apoc.export.csv.query("match (m:Movie) where m.name='Matrix' return m.name","results.csv",{})");
/////
public class bolt {
public static void main(String[] args) {
Driver driver = GraphDatabase.driver("bolt://127.0.0.1:7687", AuthTokens.basic("neo4j", "neo4j"));
Session session = driver.session();
StatementResult result = session.run("CALL apoc.export.csv.query("match (m:Movie) where m.name='Matrix' return m.name","results.csv",{})");
session.close();
driver.close();
}
}
Upvotes: 0
Views: 964
Reputation: 5047
Just escape the quotation characters inside the string.
StatementResult result = session.run(
"CALL apoc.export.csv.query(\"match (m:Movie) where m.name='Matrix' return m.name\",\"results.csv\",{})"
);
Upvotes: 1