0

这个问题可能听起来很蹩脚,但我真的很困惑......这是我的正常查询代码:

public class test4query extends Object {
    public static String[] arr=new String[30];
    public  void  mai (String s) {
        String directory = "EMAILADDRESS" ;
        Dataset ds = TDBFactory.createDataset(directory) ;
        ds.begin(ReadWrite.READ) ;
        Model model = ds.getDefaultModel() ;

        QueryExecution qExec = QueryExecutionFactory.create(s, ds) ;
        int i=0;
        try{
             ResultSet rs = qExec.execSelect() ;
             String x=rs.toString();

             while (rs.hasNext()) {
                 QuerySolution qs = rs.next();
                 String rds;
                 if(qs.get("x")!=null) {
                    rds = qs.get("x").toString();
                 } else {
                    rds="hi";
                 }
                 if(rds==null) {
                    break;
                 }
                 System.out.println(rds);
                 arr[i] = rds;
                 i++;   
             }
        } finally
             {qExec.close() ;
             ds.commit();
             ds.end();
        }

    }
}

但这不适用于删除查询..它显示错误:

Was expecting one of:
    "base" ...
    "prefix" ...
    "select" ...
    "describe" ...
    "construct" ...
    "ask" ...

我知道需要对更新查询进行一些更改?有人可以提供一些提示吗?任何链接都会有所帮助!

4

1 回答 1

3

SPARQL Query 和 SPARQL Update 是不同的语言,有不同的工厂来解析它们。QueryFactory用于SPARQL 1.1 查询语言。对于SPARQL 1.1 Update,您需要使用UpdateFactory

于 2014-06-23T18:12:11.640 回答