Stardog connection stuck after executing 20 queries

Hi,
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) {
//reader.readNext();
//System.out.println(record[0]);
String p = "<"+record[0]+">";
System.out.println(p);
String query = "SELECT (COUNT(*) as ?total_triples) { ?s"+p+" ?o }";
SelectQuery sparQ = connection.select(query);
System.out.println("query making...!!!");
SelectQueryResult tupleQueryResult = sparQ.execute();
System.out.println("query executed...!!!");
while(tupleQueryResult.hasNext()) {
BindingSet result = tupleQueryResult.next();
int val = Literal.intValue((Literal) result.get("total_triples"));
System.out.println(val);
System.out.println(i);
// 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.