2 Replies Latest reply on Jun 12, 2009 2:15 PM by 701963

    Import of RDF-Triple - HOW?

    701963
      Hello,

      i have some problem:

      I have just installed Oracle 11g. Now, i want to upgrade the database so that I can import RDF-Triple of the type "N3" into my Database. My questions now are:

      1. What do I have to do, to be able to import these triples? Is there any tutorial, that explaines, how I can upgrade for RDF-Import?
      2. When I successfully upgraded my database, how can I import my triples? Can I import N3-TRIPLES or do I have to convert them?

      It would be nice, if anyone can help me.

      Chris
        • 1. Re: Import of RDF-Triple - HOW?
          Mannamal-Oracle
          The semantic technologies page http://www.oracle.com/technology/tech/semantic_technologies/index.html has a training section http://www.oracle.com/technology/tech/semantic_technologies/htdocs/semtech_training.html which you will find useful. In particular the "Oracle by Example Training on RDF Semantic Data Management" will be useful.

          Melli
          • 2. Import of RDF-Triple
            701963
            Hello guys,

            I am trying to Import some N3-Triple to my Database.
            I opened SQL*PLUS and logged in with user: 'SYSTEM'

            First, I installed the RDF-stuff with SQL'PLUS by typing @catsem11i.sql;
            Then, i did the following steps:

            1) CREATE TABLESPACE rdf_tablespace
            DATAFILE '/local/oracle/app/oracle/oradata/THESEUSDl/rdf_tablespace.dat' SIZE 1024M REUSE
            AUTOEXTEND ON NEXT 256M MAXSIZE UNLIMITED
            SEGMENT SPACE MANAGEMENT AUTO;
            2) EXECUTE SDO_RDF.CREATE_RDF_NETWORK('rdf_tablespace');
            3) GRANT EXECUTE ON MDSYS.RDF_APIS_INTERNAL TO SYS;
            4) CREATE TABLE RDF_DATA (id NUMBER, triple SDO_RDF_TRIPLE_S);
            5) EXECUTE SDO_RDF.CREATE_RDF_MODEL('RDF', 'RDF_DATA', 'TRIPLE');

            Well, then I took my littel Java-file for importing the triples:

            here is my code:

            import java.io.IOException;
            import java.io.InputStream;
            import java.io.PrintStream;
            import java.sql.SQLException;

            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.OracleBulkUpdateHandler;

            import com.hp.hpl.jena.graph.GraphUtil;
            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 Import {

                 /**
                 * @param args
                 * @throws ClassNotFoundException
                 * @throws SQLException
                 * @throws IOException
                 */
                 public static void main(String[] args) throws ClassNotFoundException,
                           SQLException, IOException {
                      PrintStream psOut = System.out;
                      String tbs = "rdf_tablespace";
                      int method = 1;
                      String className = "oracle.jdbc.driver.OracleDriver"; // path of driver
                      // class
                      Class.forName(className); // Load the Driver
                      String DB_URL = "jdbc:oracle:thin:@URL:1521:THESEUSDB"; // URL of database
                      String DB_USER = "SYSTEM"; // database user id
                      String DB_PASSWD = "secret_pw"; // database password
                      String DB = "Oracle"; // database type

                      // Create database connection
                      Oracle oracle = new Oracle(DB_URL, DB_USER, DB_PASSWD);

                      // darf nicht mit einer zahl anfangen
                      String modelName = "onehoundred";
                      
                      // create or open the default model
                      Model model = ModelFactory.createDefaultModel();
                      GraphOracleSem graph = new GraphOracleSem(oracle, modelName);
                      // read data
                      String filename = "C:\\Path\\sp2b_100000.n3";
                      InputStream is = FileManager.get().open(filename);
                      
                      // for n3 files
                      model.read(is, "", "N3");

                      is.close();

                      ModelOracleSem modelDest = ModelOracleSem.createOracleSemModel(oracle,
                                modelName);

                      GraphOracleSem g = modelDest.getGraph();
                      g.dropApplicationTableIndex();

                      //batch
                           psOut.println("start batch load");
                           ((OracleBulkUpdateHandler) g.getBulkUpdateHandler()).addInBatch(
                                     GraphUtil.findAll(model.getGraph()), tbs);
                           psOut.println("end size " + modelDest.size());

                      g.rebuildApplicationTableIndex();
                      modelDest.close();

                      // Close the database connection
                      oracle.dispose();
                      System.out.println("Ready.");

                 }

            I run it - it takes about 3 minutes - and the i get the following result:

            start batch load
            end size 100073
            Ready.

            So far, so good. But now, i have a little problem. If i look into my Database (with DBVisualizer) , i cannot find my imported triples...
            I don't understand why. In my Java Code, I have "String tbs = "rdf_tablespace"" which I also created before with SQL*Plus. And in that tablespace should be my table "RDF_DATA", i guess. So do I understand anything wrong? Did I forget any step?
            Who can help? I am very desperate right now :-)