I am using Apache Jena 2.12.0 to query a SPARQL endpoint. I want to close my QueryEngineHTTP object after usage but the following code will result in an unusable ResultSet, as it gets closed along with the QueryEngineHTTP. Is there a way to close one, but not the other?
public ResultSet select(String query)
{
try(QueryEngineHTTP qe = new QueryEngineHTTP(ENDPOINT, query))
{
return qe.execSelect();
} catch(Exception e) {throw new RuntimeException("Error on query:\n"+query,e);}
}
if you want to detach the results from the incoming stream, you need to create a result set not driven by the incoming data - i.e. take a copy.
ResultSetFactory.copyResults
will do that for you. This result set is rewindable.