i am attempting to use the following query:
QUERY="PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
" PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
"CONSTRUCT { \n" +
"?cls ?cp ?co . \n" +
" ?prop ?pp ?po . \n" +
"}" +
"WHERE { \n" +
"?cls a rdfs:Class . \n" +
"?cls ?cp ?co . \n" +
"?prop a rdf:Property . \n" +
"?prop ?pp ?po . \n " +
"}";
results = qe.execSelect();
THe query is in string variable QUERY.
I am using jena THe Whole thing is in a interface that has 2 buttons. QUERY takes a select query when users click button1 and the above query if user clicks button2GEtting the following exception if QUERY contains both construct and select
Exception in thread "AWT-EventQueue-0" com.hp.hpl.jena.query.QueryExecException: Attempt to have ResultSet from 开发者_JAVA技巧a CONSTRUCT query at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.execSelect(QueryExecutionBase.java:93)CONSTRUCT
queries result in a model, not a result set. You need to use:
Model model = qe.execConstruct();
You can't have a query that "contains both construct and select". (unless you mean a construct containing a sub-select?)
You might find the following useful:
Query q = QueryFactory.create(QUERY);
if (q.isSelectType()) { ... execSelect, deal with results ... }
else if (q.isConstructType()) { ... execConstruct, deal with result model ... }
else { ... do you deal with DESCRIBE? ... }
精彩评论