How could I store multiple ontologies in TDB

前端 未结 2 875
被撕碎了的回忆
被撕碎了的回忆 2021-01-22 06:34

I am working on a project which need to save multiple ontologies in one TDB. I tried to do it in my own way, but it didn\'t work. Help me please..If you know how to use TDB , co

相关标签:
2条回答
  • 2021-01-22 07:26

    These helper functions work for me:

      /**
       * get a model for the given directory
       * 
       * @param directory
       * @return
       */
      public Model getModel(String directory) {
        // Make a TDB-backed dataset
        dataset = TDBFactory.createDataset(directory);
    
        // open write transaction 
        // see http://jena.apache.org/documentation/tdb/tdb_transactions.html
        dataset.begin(ReadWrite.WRITE);
        Model model = dataset.getDefaultModel();
        return model;
      }
    
      /**
       * save the given model
       * @param model
       */
      public void saveModel(Model model) {
        if (model != null && dataset != null) {
          model.commit();
          model.close();
          dataset.close();
        }
      }
    
    0 讨论(0)
  • 2021-01-22 07:28

    Which version of Jena?

    Try putting the transaction on the dataset.

    dataset.begin(ReadWrite.WRITE) ;
    

    see http://jena.apache.org/documentation/tdb/tdb_transactions.html

    0 讨论(0)
提交回复
热议问题