How I can use Fuseki with Jena TDB

2019-02-15 10:22发布

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. In particular, I saw that in the literature together with Jena TDB is used Fuseki. I loaded my files rdf in Jena TDB in this way:

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)?, but I have the problem.

In particular, I have downloaded Fuseki distribution and unzipped it. Then, I opened the command prompt and I went to the folder where I unzipped fuseki. Then, I launched this command:

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

and I opened the browser on localhost:3030 address. On the browser, I can choose the dataset (in the case C://TDB) and I can launch my query, for example:

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

The query result is:

Error 404: Not Found

Why? What am I doing wrong?

On Desktop SPARQL client for Jena (TDB)? post, I have read that I have to run the command:

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?

2条回答
孤傲高冷的网名
2楼-- · 2019-02-15 10:32

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.

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

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. For reference at time of writing this answer the latest version is 1.0.2

This command launches Fuseki against the TDB database located in /path/to/database with the dataset path of /ds. 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.

If you are running on Windows (which appears to be the case from your question) then you would do the following:

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.

查看更多
Juvenile、少年°
3楼-- · 2019-02-15 10:56
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

"C:\jena-fuseki-1.0.1"
查看更多
登录 后发表回答