Neo4j cypher query collect() return Array in result. In order to iterate it we need it to add in arrayList. The previous process we used is not helping us and throwing an exception.
PREVIOUS CODE:-
public String GettingCurrentDate() {
Connection connect = null;
String query=null;
try {
connect = graphdbConnect();
Statement stmt = connect.createStatement();
query="match(n:learner) "
+ " return collect(n.name) as ids";
System.out.println(query);
ResultSet rs = stmt.executeQuery(query.toLowerCase());
while(rs.next()){
Array idsList=rs.getArray("ids");
System.out.println("idsList :: "+idsList);
ArrayList<String> userIds = new ArrayList<>();
String[] userIdsArray = (String[])rs.getArray("ids").getArray();
for(String id : userIdsArray) {
userIds.add(id);
System.out.println(userIds+"------userId");
}
}
}
catch(Exception e) {
e.printStackTrace();
} finally {
if(connect!=null) {
try {
connect.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return "sucess";
}
This code is getting exception java.sql.SQLFeatureNotSupportedException: get array
Question:- HOW WILL WE GET THE DATA FROM COLLECT() function and iterate it