【发布时间】:2011-04-11 14:36:00
【问题描述】:
我有一个本地版本的 N-Triples 格式的 LinkedMDB,我想查询它。现在,我想使用Jena TDB,它可以存储可以用于以后查询的数据。我检查了documentation for TDB Java API,但无法加载 N-Triples 文件,然后使用 SPARQL 进行查询。我使用了以下代码:
String directory = "E:\\Applications\\tdb-0.8.9\\TDB-0.8.9\\bin\\tdb";
Dataset dataset = TDBFactory.createDataset(directory);
// assume we want the default model, or we could get a named model here
Model tdb = dataset.getDefaultModel();
// read the input file - only needs to be done once
String source = "E:\\Applications\\linkedmdb-18-05-2009-dump.nt";
FileManager.get().readModel( tdb, source, "N-TRIPLES" );
并得到以下异常
Exception in thread "main" com.hp.hpl.jena.tdb.base.file.FileException: Not a directory: E:\Applications\tdb-0.8.9\TDB-0.8.9\bin\tdb
at com.hp.hpl.jena.tdb.base.file.Location.<init>(Location.java:83)
at com.hp.hpl.jena.tdb.TDBFactory.createDataset(TDBFactory.java:79)
at tutorial.Temp.main(Temp.java:14)
【问题讨论】:
-
如果目录
E:\Applications\tdb-0.8.9\TDB-0.8.9\bin\tdb尚不存在,您必须先创建它。但是,您可能应该将数据存储在您安装 TDB 的位置以外的目录中(即特定于您的应用程序的目录)。例如,考虑下载 TDB 的未来版本时会发生什么。