3 Replies Latest reply on Jun 14, 2010 8:03 PM by JorgeB-Oracle

    NTripleConverter class issue in 11g

      I'm trying to move some RDF model data from one database to another. Here are my steps.
      1. Export existing RDF Model data to NTriple format file from source, using NTripleConverter class.
      2. Transfer the file to the new server where target db is running.
      3. Import NTriple file into RDF Model in target db, using the same NTripleConverter class.

      I downloaded sdordf_converter.zip file from OTN, modified and compiled the TestNDM2NTriple.java class without problem. However, when I ran the program, I got these errors:

      C:\>java -classpath .;%ORACLE_HOME%\jdbc\lib\ojdbc14.jar;.\sdordfclient.jar TestNDM2NTriple org.nt 13
      java.sql.SQLException: ORA-00904: "D"."REIF_LINK": invalid identifier
      Non-privileged user or invalid modelName/modelID

      Looking into the NTripleConverter.java file, it failed on this query:

      SELECT b.value_name.GETURL () sub,
      a.value_name.GETURL () prop,
      c.value_name.GETURL () obj,
      c.long_value llit,
      c.literal_type lt,
      c.language_type lang
      WHERE d.model_id = 13
      AND d.reif_link = 'N'
      AND d.p_value_id = a.value_id
      AND d.start_node_id = b.value_id
      AND d.end_node_id = c.value_id;

      because the RDF_LINK$ table does not contain a REIF_LINK column in 11g. (This is different from the old 10gR2).

      How should I accomplish what I set out to do: Move RDF Model data from one db to another in 11g?
        • 1. Re: NTripleConverter class issue in 11g
          Hi Bin,

          As you pointed out the column does not exist in 11g

          The Ntriple converter you are using is not valid for 11g, just 10g

          In 11g you can use the jena adaptor to convert a model into Ntriple then load it in another database:

          I know you are able to log into My Oracle Support.
          Review the following note:

          How To Convert An RDF/XML file to NTriple Format Using Jena (Doc ID 464520.1)

          • 2. Re: NTripleConverter class issue in 11g
            Thanks for your help. Follow the doc, it appears that I have to create an XML file first (the my_ontology.xml in the example). Since my model data is in the source database, how should I create a RDF/XML file from the db? Also, is it possible to run Jena directly against the database to create NTriple Format file?
            • 3. Re: NTripleConverter class issue in 11g
              Hi Bin,

              In order to dump an existing model to N-Triple format do the following:

              cd <JENA_DIR>/lib

              create file dump_model.java:

              import java.io.*;
              import com.hp.hpl.jena.query.*;
              import com.hp.hpl.jena.rdf.model.Model;
              import com.hp.hpl.jena.util.FileManager;
              import oracle.spatial.rdf.client.jena.*;

              public class dump_model
              public static void main(String[] args) throws Exception
              String szJdbcURL = args[0];
              String szUser = args[1];
              String szPasswd = args[2];

              String szModelName = args[3];

              Oracle oracle = new Oracle(szJdbcURL, szUser, szPasswd);
              Model model = ModelOracleSem.createOracleSemModel(oracle, szModelName);

              OutputStream os = new FileOutputStream("./output.nt");
              model.write(os, "N-TRIPLE");


              To compile:
              javac -classpath ./:./jena-2.6.2.jar:./sdordfclient.jar:./ojdbc5.jar:slf4j-api-1.5.6.jar:log4j-1.2.13.jar:slf4j-log4j12-1.5.6.jar:arq-2.8.1.jar:xercesImpl-2.7.1.jar dump_model.java

              Change rdfusr rdfusr family to <user> <password> <model_name> in the next line. Change also @machine.domain:1521:orcl for your connection info
              -- To run:
              java -classpath ./:./jena-2.6.2.jar:./sdordfclient.jar:./ojdbc5.jar:slf4j-api-1.5.6.jar:log4j-1.2.13.jar:slf4j-log4j12-1.5.6.jar:arq-2.8.1.jar:xercesImpl-2.7.1.jar:iri-0.7.jar:icu4j-3.4.4.jar dump_model jdbc:oracle:thin:@machine.domain:1521:orcl rdfusr rdfusr family

              The N-Triple file output.nt should be created in <JENA_DIR>/lib