简体   繁体   English

Jena Fuseki:创建数据集无效

[英]Jena Fuseki: Creation of Dataset does not work

I have Jena Fuseki database running on my localhost and I am trying to create a new dataset via the following Java code: 我在本地主机上运行了Jena Fuseki数据库,并且尝试通过以下Java代码创建新的数据集:

public static Dataset createDataset() {
    Dataset dataset = TDBFactory.createDataset("http://localhost:3030/testDataset");

    return dataset;
}

public static void main(String[] argv) {
    createDataset();
}

My Java console shows the following output: 我的Java控制台显示以下输出:

Exception in thread "main" org.apache.jena.tdb.TDBException: Does not exist: /Users/Philip/IdeaProjects/Squirrel_copy/http:/localhost:3030/testDataset/
at org.apache.jena.tdb.setup.DatasetBuilderStd.error(DatasetBuilderStd.java:321)
at org.apache.jena.tdb.setup.DatasetBuilderStd.checkLocation(DatasetBuilderStd.java:139)
at org.apache.jena.tdb.setup.DatasetBuilderStd.build(DatasetBuilderStd.java:161)
at org.apache.jena.tdb.setup.DatasetBuilderStd.create(DatasetBuilderStd.java:90)
at org.apache.jena.tdb.StoreConnection.make(StoreConnection.java:208)
at org.apache.jena.tdb.StoreConnection.make(StoreConnection.java:215)
at org.apache.jena.tdb.transaction.DatasetGraphTransaction.<init>(DatasetGraphTransaction.java:65)
2018-01-21 17:08:03,092 [main] ERROR [o.a.j.info                    ] - <Does not exist: /Users/Philip/IdeaProjects/Squirrel_copy/http:/localhost:3030/testDataset/>
at org.apache.jena.tdb.sys.TDBMaker._create(TDBMaker.java:55)
at org.apache.jena.tdb.sys.TDBMaker.createDatasetGraphTransaction(TDBMaker.java:42)
at org.apache.jena.tdb.TDBFactory._createDatasetGraph(TDBFactory.java:89)
at org.apache.jena.tdb.TDBFactory.createDatasetGraph(TDBFactory.java:71)
at org.apache.jena.tdb.TDBFactory.createDataset(TDBFactory.java:55)
at org.apache.jena.tdb.TDBFactory.createDataset(TDBFactory.java:51)
at org.aksw.simba.squirrel.sink.RDFSink.createDataset(RDFSink.java:43)
at org.aksw.simba.squirrel.sink.RDFSink.main(RDFSink.java:49)

The problem seems to be that the Java method tries to store the dataset in the location 问题似乎是Java方法试图将数据集存储在该位置

/Users/Philip/IdeaProjects/Squirrel_copy/localhost:3030/testDataset/

with the unnecessary prefix of my local file system and I do not know how to remove this prefix. 使用本地文件系统不必要的前缀,并且我不知道如何删除此前缀。

The method you've used seems somewhat under-documented, but if you look at a similar method here: https://jena.apache.org/documentation/javadoc/tdb/org/apache/jena/tdb/TDBFactory.html#createDataset-org.apache.jena.tdb.base.file.Location- 您使用的方法似乎文档不足,但是如果您在此处查看类似的方法: https : //jena.apache.org/documentation/javadoc/tdb/org/apache/jena/tdb/TDBFactory.html# createDataset-org.apache.jena.tdb.base.file.Location-

with the signature 签名

public static Dataset createDataset(org.apache.jena.tdb.base.file.Location location)

then it suggests that this factory method expects a path to a directory in your file system, not the url on which your server is listening. 则表明此工厂方法需要文件系统中目录的路径,而不是服务器正在侦听的URL。 The name of the String -type argument is dir , which also indicates that a path to a directory is expected. String -type参数的名称为dir ,它还指示需要目录的路径。

If you want to create a new dataset on a running fuseki server, consider making use of fuseki's HTTP-based administration protocol, described here: https://jena.apache.org/documentation/fuseki2/fuseki-server-protocol.html#datasets-and-services . 如果要在正在运行的funkki服务器上创建新的数据集,请考虑使用fuseki的基于HTTP的管理协议,如下所述: https : //jena.apache.org/documentation/fuseki2/fuseki-server-protocol.html#数据集和服务 This is not exactly a SPARQL query, and it uses http POST requests, but it should do what you want. 这不完全是一个SPARQL查询,它使用http POST请求,但是它应该执行您想要的操作。

public void setup() throws IOException 
{ 
  ds = DatasetFactory.createTxnMem();
  server = FusekiServer.create().add("/ds", ds).build();
  server.start();
}

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

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