Stardog connection stuck after executing 20 queries

when I am executing queries in a loop using java. It got stuck after 20 iterations, means after execution of 20 queries.
code below:

while ((record = reader.readNext()) != null) {
String p = "<"+record[0]+">";
String query = "SELECT (COUNT(*) as ?total_triples) { ?s"+p+" ?o }";
SelectQuery sparQ =;
System.out.println("query making...!!!");
SelectQueryResult tupleQueryResult = sparQ.execute();
System.out.println("query executed...!!!");
while(tupleQueryResult.hasNext()) {
BindingSet result =;
int val = Literal.intValue((Literal) result.get("total_triples"));
// predicatesJson.put(record[0], val);
// System.out.println(Literal.integerValue((Literal) result.get("total_triples")));


it got stuck in "SelectQueryResult tupleQueryResult = sparQ.execute();" line.
basically, I am reading predicates from a csv file, and for each predicate I am executing a query to find out no of triples associated with this predicate.
But this program is got stuck after executing 20 iterations.
Please help me to solve this. ?

I’m in my phone right now so it’s hard to look closely but I don’t thing you’re closing your results. Make sure you close the results after each iteration. It’s auto Closable so you can use a try with resources.

Thanks @zachary.whitley . It worked....!!!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.