0

I have made an ontology on Protege. it has . owl extension. I am trying to import this ontology in oracle 12c using jena. but model. Read method requires an rdf file. I am giving the code as well as error. Kindly help me in this case.

error

Exception in thread "main" com.hp.hpl.jena.shared.JenaException: java.lang.UnsatisfiedLinkError: no ocijdbc11 in java.library.path
    at oracle.spatial.rdf.client.jena.Oracle.<init>(Oracle.java:207)
    at test.TestClass.main(TestClass.java:26)

code package test;

import java.io.InputStream;
import com.hp.hpl.jena.rdf.model.*;
import oracle.spatial.rdf.client.jena.GraphOracleSem;
import oracle.spatial.rdf.client.jena.ModelOracleSem;
import oracle.spatial.rdf.client.jena.Oracle;
import oracle.spatial.rdf.client.jena.OracleUtils;
import com.hp.hpl.jena.graph.GraphUtil;
import com.hp.hpl.jena.graph.Triple;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.util.FileManager;

public class TestJena{
    public static void main(String[] args) throws Exception
    {
        //String szJdbcURL = args[0];
        //String szUser = args[1];
        //String szPasswd = args[2];
        //String szModelName = args[3];
        // in memory Jena Model
        Model model = ModelFactory.createDefaultModel();
        InputStream is = FileManager.get().open("E:/abcd.owl");
        model.read(is, "", "RDF/XML");
        is.close();

        Oracle oracle = new Oracle("jdbc:oracle:oci8:@", "c##hr_admin","Hira123");

        ModelOracleSem modelDest = ModelOracleSem.createOracleSemModel(oracle,"M1");
        GraphOracleSem g = modelDest.getGraph();
        g.dropApplicationTableIndex();
        int method = 2; // try bulk loader
        String tbs = "SYSAUX"; // can be customized
        if (method == 0) {
            System.out.println("start incremental");
            modelDest.add(model);
            System.out.println("end size " + modelDest.size());
        }
        else if (method == 1) {
            System.out.println("start batch load");
            g.getBulkUpdateHandler().addInBatch(
            GraphUtil.findAll(model.getGraph()), tbs);
            System.out.println("end size " + modelDest.size());
        }
        else {
            System.out.println("start bulk load");
            g.getBulkUpdateHandler().addInBulk(
            GraphUtil.findAll(model.getGraph()), tbs);
            System.out.println("end size " + modelDest.size());
        }
        g.rebuildApplicationTableIndex();
        long lCount = g.getCount(Triple.ANY);
        System.out.println("Asserted triples count: " + lCount);
        model.close();
        OracleUtils.dropSemanticModel(oracle, "M1");
        oracle.dispose();
    }
}
Racil Hilan
  • 24,690
  • 13
  • 50
  • 55

1 Answers1

0

You can rename the file to RDF: under the assumption that the format you used for the ontology is RDF/XML (the default), all that is needed is changing the file extension.

Regarding the error you post, you are missing a binary library. You need to set java.library.path to point at the folder containing the library mentioned in the error. See for example how to set java library path for processing for how to do this.

Community
  • 1
  • 1
Ignazio
  • 10,504
  • 1
  • 14
  • 25