找不到 QueryFactory 的符号 - jena API
import java.io.*;
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype.*;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.db.*;
import com.hp.hpl.jena.db.impl.*;
import com.hp.hpl.jena.graph.compose.*;
import com.hp.hpl.jena.graph.query.*;
import com.hp.hpl.jena.graph.*;
import com.hp.hpl.jena.vocabulary.*;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.rdf.model.ModelMaker.*;
import com.hp.hpl.jena.mem.*;
import com.hp.hpl.jena.mem.faster.*;
class Firstsparql{
public static void main(String[] args){
// Open the bloggers RDF graph from the filesystem
InputStream in = new FileInputStream(new File("foaf.rdf"));
// Create an empty in-memory model and populate it from the graph
Model model = ModelFactory.createMemModelMaker().createModel();
model.read(in,null); // null base URI, since model URIs are absolute
in.close();
// Create a new query
String queryString =
"PREFIX foaf: <http://xmlns.com/foaf/0.1/> " +
"SELECT ?url " +
"WHERE {" +
" ?contributor foaf:name \"Jon Foobar\" . " +
" ?contributor foaf:weblog ?url . " +
" }";
Query query = QueryFactory.create(queryString);
// Execute the query and obtain results
QueryExecution qe = QueryExecutionFactory.create(query, model);
ResultSet results = qe.execSelect();
// Output query results
ResultSetFormatter.out(System.out, results, query);
// Important – free up resources used running the query
qe.close();
}
}
您好,我已将 jena.jar 文件包含在我的类路径中,但仍然有一些变量和方法无法识别。我希望它们没有在 jena api 中定义..还有我需要包含的其他 api..请告诉我..知道。谢谢。
import java.io.*;
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype.*;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.db.*;
import com.hp.hpl.jena.db.impl.*;
import com.hp.hpl.jena.graph.compose.*;
import com.hp.hpl.jena.graph.query.*;
import com.hp.hpl.jena.graph.*;
import com.hp.hpl.jena.vocabulary.*;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.rdf.model.ModelMaker.*;
import com.hp.hpl.jena.mem.*;
import com.hp.hpl.jena.mem.faster.*;
class Firstsparql{
public static void main(String[] args){
// Open the bloggers RDF graph from the filesystem
InputStream in = new FileInputStream(new File("foaf.rdf"));
// Create an empty in-memory model and populate it from the graph
Model model = ModelFactory.createMemModelMaker().createModel();
model.read(in,null); // null base URI, since model URIs are absolute
in.close();
// Create a new query
String queryString =
"PREFIX foaf: <http://xmlns.com/foaf/0.1/> " +
"SELECT ?url " +
"WHERE {" +
" ?contributor foaf:name \"Jon Foobar\" . " +
" ?contributor foaf:weblog ?url . " +
" }";
Query query = QueryFactory.create(queryString);
// Execute the query and obtain results
QueryExecution qe = QueryExecutionFactory.create(query, model);
ResultSet results = qe.execSelect();
// Output query results
ResultSetFormatter.out(System.out, results, query);
// Important – free up resources used running the query
qe.close();
}
}
Hi, i have included jena.jar file in my classpath but still some of variables and methods are not recognised. ihope they are not defined in jena api..is there any other api i need to include.pls..let me..know. thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的
CLASSPATH
需要包含 Jena lib 目录中的所有.jar
文件,而不仅仅是jena.jar
。Your
CLASSPATH
needs to include all of the.jar
files in the Jena lib directory, not justjena.jar
.除了上面的建议之外,您还可以在 https://jena.apache.org/documentation
特别是,Jena 用于处理 SPARQL 查询的部分称为 ARQ。 ARQ.jar涉及QueryFactory。
Apart from advise above, you can read about jena's architecture on https://jena.apache.org/documentation
Particularly, Jena's part for process SPARQL query called ARQ. ARQ.jar involves QueryFactory.