This is what I wrote:
public static void main(String[] args) {
Dataset dataset = TDBFactory.createDataset("/tmp/someThings");
dataset.begin(ReadWrite.WRITE);
Model model = dataset.getDefaultModel();
model.setNsPrefix("kg", "http://sankuai.com/kg");
Resource resource = model.createResource("http://sankuai.com/kg/jena");
resource.addProperty(model.createProperty("kg", "language"), "SPARQL");
dataset.commit();
System.out.println(model);
}
But instead give me some output, It shows an error:
Exception in thread "main" org.apache.jena.tdb.transaction.TDBTransactionException: Not in a transaction
has there something I done was wrong?
The problem is when I retrieve a model:
System.out.println(model);
It must be contained in a transaction, which I am not...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With