如果我想通过 Netbeans 在 Sesame 存储库中执行 SPARQL SELECT 查询,我使用以下代码(并且我在绑定集中获得三个值)。如何进行只返回一个布尔值的 ASK 查询?
TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
TupleQueryResult result = tupleQuery.evaluate();
List<String> bindingNames = result.getBindingNames();
try {
while (result.hasNext()) {
BindingSet bindingSet = result.next();
Value firstValue1 = bindingSet.getValue(bindingNames.get(0));
Value firstValue2 = bindingSet.getValue(bindingNames.get(1));
Value firstValue3 = bindingSet.getValue(bindingNames.get(2));
}
}