use of org.apache.jena.sparql.resultset.ResultSetException in project jena by apache.
the class query method queryExec.
protected void queryExec(boolean timed, ResultsFormat fmt) {
try {
Query query = modQuery.getQuery();
if (isVerbose()) {
IndentedWriter out = new IndentedWriter(System.out, true);
query.serialize(out);
out.flush();
System.out.println();
}
if (isQuiet())
LogCtl.setError(SysRIOT.riotLoggerName);
Dataset dataset = getDataset(query);
// The default policy is to create an empty one - convenience for VALUES and BIND providing the data.
if (dataset == null && !query.hasDatasetDescription()) {
System.err.println("Dataset not specified in query nor provided on command line.");
throw new TerminationException(1);
}
Transactional transactional = (dataset != null && dataset.supportsTransactionAbort()) ? dataset : new TransactionalNull();
Txn.executeRead(transactional, () -> {
modTime.startTimer();
try (QueryExecution qe = QueryExecutionFactory.create(query, dataset)) {
try {
QueryExecUtils.executeQuery(query, qe, fmt);
} catch (QueryCancelledException ex) {
System.out.flush();
System.err.println("Query timed out");
}
long time = modTime.endTimer();
if (timed) {
totalTime += time;
System.err.println("Time: " + modTime.timeStr(time) + " sec");
}
} catch (ResultSetException ex) {
System.err.println(ex.getMessage());
ex.printStackTrace(System.err);
} catch (QueryException qEx) {
// System.err.println(qEx.getMessage()) ;
throw new CmdException("Query Exeception", qEx);
}
});
} catch (ARQInternalErrorException intEx) {
System.err.println(intEx.getMessage());
if (intEx.getCause() != null) {
System.err.println("Cause:");
intEx.getCause().printStackTrace(System.err);
System.err.println();
}
intEx.printStackTrace(System.err);
} catch (JenaException | CmdException ex) {
throw ex;
} catch (Exception ex) {
throw new CmdException("Exception", ex);
}
}
use of org.apache.jena.sparql.resultset.ResultSetException in project jena by apache.
the class ReaderTriX method read.
@Override
public void read(Reader reader, String baseURI, ContentType ct, StreamRDF output, Context context) {
XMLInputFactory xf = XMLInputFactory.newInstance();
XMLStreamReader xReader;
try {
xReader = xf.createXMLStreamReader(reader);
} catch (XMLStreamException e) {
throw new ResultSetException("Can't initialize StAX parsing engine", e);
}
read(xReader, baseURI, output);
}
use of org.apache.jena.sparql.resultset.ResultSetException in project jena by apache.
the class qparse method exec.
@Override
protected void exec() {
try {
Query query = modQuery.getQuery();
try {
LogCtl.disable(ParserBase.ParserLoggerName);
QueryUtils.checkQuery(query, true);
} catch (QueryCheckException ex) {
System.err.println();
System.err.println("**** Check failure: " + ex.getMessage());
if (ex.getCause() != null)
ex.getCause().printStackTrace(System.err);
} finally {
LogCtl.setLevel(ParserBase.ParserLoggerName, "INFO");
}
// Print the query out in some syntax
if (printQuery) {
divider();
modOutput.output(query);
}
// Print internal forms.
if (printOp) {
divider();
modOutput.outputOp(query, false);
}
if (printQuad) {
divider();
modOutput.outputQuad(query, false);
}
if (printOpt) {
divider();
modOutput.outputOp(query, true);
}
if (printQuadOpt) {
divider();
modOutput.outputQuad(query, true);
}
if (printPlan) {
divider();
// This forces internal query initialization - must be after QueryUtils.checkQuery
QueryExecution qExec = QueryExecutionFactory.create(query, DatasetFactory.createGeneral());
QueryOutputUtils.printPlan(query, qExec);
}
} catch (ARQInternalErrorException intEx) {
System.err.println(intEx.getMessage());
if (intEx.getCause() != null) {
System.err.println("Cause:");
intEx.getCause().printStackTrace(System.err);
System.err.println();
}
intEx.printStackTrace(System.err);
} catch (ResultSetException ex) {
System.err.println(ex.getMessage());
ex.printStackTrace(System.err);
} catch (QueryException qEx) {
//System.err.println(qEx.getMessage()) ;
throw new CmdException("Query Exeception", qEx);
} catch (JenaException ex) {
ex.printStackTrace();
throw ex;
} catch (CmdException ex) {
throw ex;
} catch (Exception ex) {
throw new CmdException("Exception", ex);
}
}
Aggregations