简体   繁体   English

如何使用Fuseki和Jena TDB

[英]How I can use Fuseki with Jena TDB

I have a question for you. 我有一个问题问你。

I have a triplestore "Jena TDB" and I have read that I can set up a SPARQL endpoint for locally stored RDF data. 我有一个三元店“Jena TDB”,我读过我可以为本地存储的RDF数据设置SPARQL端点。 In particular, I saw that in the literature together with Jena TDB is used Fuseki. 特别是,我在文献中看到,与耶拿TDB一起使用的是Fuseki。 I loaded my files rdf in Jena TDB in this way: 我以这种方式在Jena TDB中加载了我的文件rdf:

public void store(){
    String directory = "C:\\tdb";
    String source = "C:\\file1.rdf";
    String source1 = "C:\\file2.rdf";
    Dataset dataset = openTDB(directory);
    Model tdb = loadModel(source, dataset);
    dataset.addNamedModel("File1", tdb);

    Model tdb1 = loadModel(source1, dataset);
    dataset.addNamedModel("File2", tdb1);

    tdb.close();
    tdb1.close();
    dataset.close();
}


public Dataset openTDB(String directory){
    // open TDB dataset
    Dataset dataset = TDBFactory.createDataset(directory);
    return dataset;
}


public Model loadModel(String source, Dataset dataset){

    Model tdb = ModelFactory.createDefaultModel();
    FileManager.get().readModel( tdb, source, "RDF/XML" );
    return tdb;
}

I am reading the Fuseki documentation on Apache site and this post Desktop SPARQL client for Jena (TDB)? 我正在阅读Apache网站上的Fuseki文档和这篇针对Jena(TDB)的Desktop SPARQL客户端文章 , but I have the problem. ,但我有问题。

In particular, I have downloaded Fuseki distribution and unzipped it. 特别是,我已经下载了Fuseki发行版并解压缩了它。 Then, I opened the command prompt and I went to the folder where I unzipped fuseki. 然后,我打开命令提示符,然后我去了解压缩fuseki的文件夹。 Then, I launched this command: 然后,我启动了这个命令:

fuseki-server --update --mem /C://TDB

and I opened the browser on localhost:3030 address. 我在localhost:3030地址上打开了浏览器。 On the browser, I can choose the dataset (in the case C://TDB) and I can launch my query, for example: 在浏览器上,我可以选择数据集(在C:// TDB的情况下),我可以启动我的查询,例如:

select * {graph ; select * {graph; { ?s ?p ?o }} {?s?p?o}}

The query result is: 查询结果为:

Error 404: Not Found 未找到错误404

Why? 为什么? What am I doing wrong? 我究竟做错了什么?

On Desktop SPARQL client for Jena (TDB)? Jena(TDB)的桌面SPARQL客户端上? post, I have read that I have to run the command: 发布,我已经读过我必须运行命令:

java -jar fuseki-0.1.0-server.jar --update --loc data /dataset java -jar fuseki-0.1.0-server.jar --update --loc data / dataset

but I don't understand who are data and dataset. 但我不明白谁是数据和数据集。 In my case, how I can know this values? 就我而言,我怎么知道这个价值观? Is this my error? 这是我的错误吗?

You are right in that you haven't understood the intent of each argument. 你是对的,你没有理解每个论点的意图。 With your command what you've done is create an empty in-memory dataset and assign it the dataset path /C://TDB which is almost certainly not what you intended. 使用您的命令您所做的是创建一个空的内存数据集并为其分配数据集路径/C://TDB ,这几乎肯定不是您的意图。

The --loc argument is used to pass in the path to a directory containing a TDB database while the /dataset path is the dataset path you want to use to access it via Fuseki --loc参数用于将路径传递到包含TDB数据库的目录,而/dataset路径是您要用于通过Fuseki访问它的数据集路径

So for example you might do the following: 例如,您可以执行以下操作:

java -jar fuseki-VER-server.jar --update --loc /path/to/database /ds

Note That I've used VER as a placeholder for the Fuseki version here since that value will depend on which version of Fuseki you have downloaded. 注意我在这里使用VER作为Fuseki版本的占位符,因为该值将取决于您下载的Fuseki版本。 For reference at time of writing this answer the latest version is 1.0.2 在撰写本答案时作为参考,最新版本为1.0.2

This command launches Fuseki against the TDB database located in /path/to/database with the dataset path of /ds . 此命令使用/ds的数据集路径针对位于/path/to/database中的TDB数据库启动Fuseki。 Therefore you can point your chosen SPARQL client at http://localhost:3030/ds/query to make queries or http://localhost:3030/ds/update to make updates. 因此,您可以将所选的SPARQL客户端指向http://localhost:3030/ds/query以进行查询,或者将http://localhost:3030/ds/update指向进行更新。

If you are running on Windows (which appears to be the case from your question) then you would do the following: 如果您在Windows上运行(您的问题似乎就是这种情况),那么您将执行以下操作:

java -jar fuseki-VER-server.jar --update --loc C:\TDB /ds

Which launches Fuseki against the TDB database located in C:\\TDB with the dataset path of /ds so the same URLs as the previous example would apply. 这将使用/ds的数据集路径针对位于C:\\TDB中的TDB数据库启动Fuseki,因此将应用与前一示例相同的URL。

first download jena fusaki from

https://jena.apache.org/download/index.cgi

un-zip the file and copy the "jena-fuseki-1.0.1" to c drive
open cmd
type for accesing the folder

"cd C:\jena-fuseki-1.0.1"

then type 然后键入

"java -jar fuseki-server.jar --update --loc data /dataset"

at last open a browser and type 最后打开一个浏览器并输入

"localhost:3030/"

remember you must first declear the enviorment verible(located in system poperties then advance tab) and edit variable name call "Path" in the "System verible" to 记住你必须首先清除环境verible(位于系统属性然后提前选项卡)并在“System verible”中编辑变量名称调用“Path”

"C:\jena-fuseki-1.0.1"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM