5 Replies Latest reply on Oct 22, 2014 12:16 PM by alwu-Oracle

    Read an existing model (12c + with oracle database option tripled)


      I've seen some code examples, all use the class "oracle.spatial.rdf.client.jena.ModelOracleSem.createOracleSemModel (oracle, string);" which creates an RDF model, but I have already created with use SQLplus, and I want to make a simple READ. Is there a way to make ?


      NB: my journey was as follows, I realized this tutorial (everything works fine), but now I want to reproduce CRUD queries on the Family model (which is extracted from the Oracle documentation) using JAVA the Jena API.


      code :

      OracleThin.createOracleSemModel(oracleThin.getOracle(), modelName);



        • 1. Re: Read an existing model (12c + with oracle database option tripled)



          I am trying to understand  your question. So you have four models and I assume you want to run a SPARQL query against the union of the four models, right? If that is your goal, you can do something like:



              String[] modelNames = new String[]{"datebaseeva", "datebaselocalebackup", "datebaseMesuresMains"}; 
              String[] rulebases =new String[]{};


              Attachment attachment = Attachment.createInstance(modelNames, 



          // The following allows us to attach EVA, LOCALEBACKUP, MESURESMAINS to the LOCALE model


              GraphOracleSem graph = new GraphOracleSem(oracle , "datebaselocale", attachment, true); 


          String queryString =

            "PREFIX ORACLE_SEM_FS_NS:   <http://oracle.com/semtech#allow_dup=t> " + ___PUT_YOUR_QUERY_HERE___;


          ModelOracleSem m = new ModelOracleSem(graph);

          Query query = QueryFactory.create(queryString);


          // Now, the following query will run against the 4 models.

          QueryExecution qe = QueryExecutionFactory.create(query, m);


          Hope it helps,


          Zhe Wu

          • 2. Re: Read an existing model (12c + with oracle database option tripled)

            On Target :

            When I use createOracleSemModel(oracle, "FAMILY"); I have the following error message :



            Building Oracle12c 1.0-SNAPSHOT



            --- exec-maven-plugin:1.2.1:exec (default-cli) @ Oracle12c ---

            Oct 07, 2014 4:05:52 PM ca.ireq.liost.oracle12c.connect.OracleThin <init>

            INFO: Connection try ... : jdbc:oracle:thin:@liost:1521:LIOST with user odemardfusr

            Oct 07, 2014 4:05:53 PM ca.ireq.liost.oracle12c.connect.OracleThin createOracleSemModel

            SEVERE: Erreur of createOracleSemModel :72000

            java.sql.SQLException: ORA-13199: Error in SDO_RDF.CREATE_RDF_MODEL: SQLERRM=ORA-55317: model "FAMILY" already exists dss=SELECT count("TRIPLE") FROM "FAMILY_TPL"

            ORA-06512: at "MDSYS.MD", line 1723

            ORA-06512: at "MDSYS.MDERR", line 17

            ORA-06512: at "MDSYS.SDO_RDF", line 1913

            ORA-06512: at line 1


            at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)

            at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)

            at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1017)

            at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:655)

            at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:249)

            at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:566)

            at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:210)

            at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:53)

            at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:938)

            at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1075)

            at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3820)

            at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3923)

            at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:5617)

            at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1385)

            at oracle.spatial.rdf.client.jena.Oracle.executeCall(Oracle.java:756)

            at oracle.spatial.rdf.client.jena.OracleModelBase.createTables(OracleModelBase.java:2245)

            at oracle.spatial.rdf.client.jena.GraphOracleSem.createTables(GraphOracleSem.java:977)

            at oracle.spatial.rdf.client.jena.GraphOracleSem.<init>(GraphOracleSem.java:853)

            at oracle.spatial.rdf.client.jena.GraphOracleSem.<init>(GraphOracleSem.java:762)

            at oracle.spatial.rdf.client.jena.GraphOracleSem.<init>(GraphOracleSem.java:663)

            at oracle.spatial.rdf.client.jena.GraphOracleSem.<init>(GraphOracleSem.java:509)

            at oracle.spatial.rdf.client.jena.ModelOracleSem.createOracleSemModel(ModelOracleSem.java:86)

            at ca.ireq.liost.oracle12c.connect.OracleThin.createOracleSemModel(OracleThin.java:32)

            at ca.ireq.liost.oracle12c.crud.Select.<init>(Select.java:26)

            at ca.ireq.liost.oracle12c.crud.Select.main(Select.java:57)



            BUILD SUCCESS


            Total time: 3.948s

            Finished at: Tue Oct 07 16:05:53 EDT 2014

            Final Memory: 5M/123M





            another method to do a reading?

            • 3. Re: Read an existing model (12c + with oracle database option tripled)



              Please try catch this SQL Exception and move on with your query.




              Zhe Wu

              • 4. Re: Read an existing model (12c + with oracle database option tripled)


                I used "new GraphOracleSem" for not triggered  exception when the Family model already exists,


                I have other questions:

                1- What is the difference between GraphOracleSem and createOracleSemModel?

                2- I have used in my project the union model with virtual media, with the aim of creating optimized model but I not saw what are the real benefits or is happening in the background in oracle?


                big thank's

                • 5. Re: Read an existing model (12c + with oracle database option tripled)



                  GraphOracleSem implements the Graph interface, while createOracleSemModel returns an instance of OracleModelSem which implements the Model interface.

                  However, you can easly wrap a graphOracleSem in a modelOracleSem object. Also you can easily get a graphOracleSem object from a modelOracleSem object.


                  Regarding 2, if you create a virtual model on top of multiple models (and/or rulebases), there is a good chance that SPARQL queries can go faster when executed against the virtual model.


                  Hope it helps,


                  Zhe Wu