Thanks for the prompt answer.


On Mon 2 Mar, 2020 11:34 pm Rob Vesse, <[email protected]> wrote:

> It's because you are trying to close the model after you've committed the
> transaction so the error message is quite correct in that you are no longer
> in a transaction at that point
>
> Put the dataset.commit() after the model.close() line and it will work
>
> Rob
>
> On 02/03/2020, 16:16, "Diptendu Dutta" <[email protected]> wrote:
>
>     I have the following code
>
>     public class JenaProcessor {
>
>     static Dataset dataset = null;
>     static String ns = "http://www.lke.com/lke.owl#";;
>
>     static {
>     try {
>     dataset =
> TDBFactory.createDataset("C:\\Users\\Diptendu\\Desktop\\lke");
>     }
>     catch(Exception ex) {
>     ex.printStackTrace();
>     }
>     }
>
>     static public void clearKnowledgeGraph(String corpus_file_id) {
>     dataset.begin(ReadWrite.WRITE) ;
>     Model model = null;
>     try {
>     model = dataset.getNamedModel(corpus_file_id);
>     model.removeAll();
>     dataset.commit();
>     if( model != null ) model.close();
>     }
>     catch(Exception ex) {
>     ex.printStackTrace();
>     }
>     finally {
>            dataset.end();
>     }
>     }
>     }
>
>     model.close() is causing the error TDBTransactionException: Not in a
>     transaction
>
>     org.apache.jena.tdb.transaction.TDBTransactionException: Not in a
>     transaction
>     at
>
> org.apache.jena.tdb.transaction.DatasetGraphTransaction.get(DatasetGraphTransaction.java:138)
>     at
>
> org.apache.jena.tdb.transaction.DatasetGraphTransaction.getDatasetGraphToQuery(DatasetGraphTransaction.java:84)
>     at
>
> org.apache.jena.tdb.store.GraphTxnTDB.getDatasetGraphTDB(GraphTxnTDB.java:51)
>     at org.apache.jena.tdb.store.GraphTDB.sync(GraphTDB.java:128)
>     at org.apache.jena.tdb.store.GraphTDB.close(GraphTDB.java:133)
>     at org.apache.jena.rdf.model.impl.ModelCom.close(ModelCom.java:1494)
>     at
> knowledgegraph.JenaProcessor.clearKnowledgeGraph(JenaProcessor.java:120)
>
>     What do I need to do?
>
>     Regards,
>
>     Diptendu Dutta
>
>
>
>
>
>

Reply via email to