未能创建Jena TDB的第一个实例

时间:2014-02-26 11:40:34

标签: java apache jena tdb

public void createDatabase(){
     // Make a TDB-backed dataset
      String directory = "MyDatabases/ex1/" ;
      Dataset dataset = TDBFactory.createDataset(directory) ;

      dataset.begin(ReadWrite.READ) ;
      // Get model inside the transaction
      Model model = dataset.getDefaultModel() ;
      dataset.end() ;

      dataset.begin(ReadWrite.WRITE) ;
      model = dataset.getDefaultModel() ;
      dataset.end() ;
}

我直接从Jena的api网页(http://jena.apache.org/documentation/tdb/java_api.html)中复制了这段非常简单的代码,试图创建一个数据库。调用createDataset时出错:

Exception in thread "main" java.lang.IllegalAccessError: tried to access method com.hp.hpl.jena.sparql.core.DatasetImpl.<init>(Lcom/hp/hpl/jena/sparql/core/DatasetGraph;)V from class com.hp.hpl.jena.tdb.TDBFactory
at com.hp.hpl.jena.tdb.TDBFactory.createDataset(TDBFactory.java:91)
at com.hp.hpl.jena.tdb.TDBFactory.createDataset(TDBFactory.java:83)
at com.hp.hpl.jena.tdb.TDBFactory.createDataset(TDBFactory.java:79)

1 个答案:

答案 0 :(得分:0)

有一些java问题 - 可能是版本冲突,或jena-arq的jar文件的文件访问问题。