6 Replies Latest reply on Oct 8, 2009 3:04 PM by alwu-Oracle

    Problem loading data from jena

    725104
      Hi, two issues when loading data into Oracle from a jena model:

      1. The incremental and batch load both works well except when we add a triple with a literal types as double:
      ...
      triple = new Triple(dirNode.asNode(), Node.createURI("http://www.w3.org/2003/01/geo/wgs84_pos#long"), Node.createLiteral(geopos.getLongitude().toString(), null,      (RDFDatatype) XSDDatatype.XSDdouble));
      graph.add(triple);

      We get the error:

      GRAVE: Could not add triple
      java.sql.BatchUpdateException: ORA-55303: Fallo en el constructor SDO_RDF_TRIPLE_S: Simple case: SQLERRM=ORA-55328: fallo al intentar insertar el valor literal "-5.9278863"^^<http://www.w3.org/2001/XMLSchema#double>
      ORA-06512: en "MDSYS.MD", línea 1723
      ORA-06512: en "MDSYS.MDERR", línea 17
      ORA-06512: en "MDSYS.SDO_RDF_TRIPLE_S", línea 211

           at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1335)
           at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3449)
           at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3530)
           at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1062)
      ........

      2. The bulk load simply does not work:

      ((OracleBulkUpdateHandler) graph.getBulkUpdateHandler()).addInBulk(GraphUtil.findAll(model.getGraph()), "sem_ts");

      We get:

      01-oct-2009 13:11:39 oracle.spatial.rdf.client.jena.SimpleLog warn
      ADVERTENCIA: addInBulk: [92 ] sqle
      java.sql.SQLException: ORA-44004: nombre de SQL cualificado no válido
      ORA-06512: en "SYS.DBMS_ASSERT", línea 188
      ORA-06512: en "MDSYS.SDO_RDF", línea 242
      ORA-06512: en "MDSYS.RDF_APIS", línea 693
      ORA-06512: en línea 1

           at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
           at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)
           at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)
      ...........

      In both case our conexion is something like:
      public static String conexion = "jdbc:oracle:thin:user/pass@ourserver:1521:ourdb";

      Any idea? Thanks
        • 1. Re: Problem loading data from jena
          alwu-Oracle
          Hmm. I cannot reproduce. Could you please try my code? Basically, it first uses incremental API to insert one triple. And then it uses
          bulk load API to add one more triple. Both triples have the double type. I am using 11.2 database.

          Oracle oracle = new Oracle(jdbcUrl, user, password);
          GraphOracleSem graph = new GraphOracleSem(oracle, modelName);
          ModelOracleSem model = new ModelOracleSem(graph);

          Model inMemoryJenaModel = ModelFactory.createDefaultModel();

          long lStartTime = System.currentTimeMillis();
          psOut.println("testCustomerMisc: start");
          Triple t = new Triple(Node.createURI("http://sub"),
          Node.createURI("http://www.w3.org/2003/01/geo/wgs84_pos#long"),
          Node.createLiteral("-5.9278863", null, (RDFDatatype) XSDDatatype.XSDdouble));
          graph.add(t);
          graph.flushAdd();

          String queryString = "SELECT * "
          + "WHERE { "
          + " ?subject ?predicate ?object . "
          + "} ";

          Query query = QueryFactory.create(queryString);
          QueryExecution qexec = QueryExecutionFactory.create(query, model);
          ResultSet results;
          {
          results = qexec.execSelect();
          ResultSetFormatter.out(psOut, results, query);
          }


          // add one more triple using bulk loader

          Triple t1 = new Triple(Node.createURI("http://sub2"),
          Node.createURI("http://www.w3.org/2003/01/geo/wgs84_pos#long"),
          Node.createLiteral("-5.888888", null, (RDFDatatype) XSDDatatype.XSDdouble));
          inMemoryJenaModel.getGraph().add(t1);

          graph.getBulkUpdateHandler().addInBulk(
          GraphUtil.findAll(inMemoryJenaModel.getGraph()), "SYSAUX");

          results = QueryExecutionFactory.create(query, model).execSelect();
          ResultSetFormatter.out(psOut, results, query);

          long lEndTime = System.currentTimeMillis();
          psOut.println("testCustomerMisc elapsed [VOLATILE] time (ms) = " + (lEndTime - lStartTime));

          graph.close();
          oracle.dispose();


          I got this output as expected...
          -----------------------------------------------------------------------------------------
          | subject | predicate | object |
          =========================================================================================
          | <http://sub> | <http://www.w3.org/2003/01/geo/wgs84_pos#long> | -5.9278862999999999E0 |
          -----------------------------------------------------------------------------------------

          ------------------------------------------------------------------------------------------
          | subject | predicate | object |
          ==========================================================================================
          | <http://sub> | <http://www.w3.org/2003/01/geo/wgs84_pos#long> | -5.9278862999999999E0 |
          | <http://sub2> | <http://www.w3.org/2003/01/geo/wgs84_pos#long> | -5.8888879999999997E0 |
          ------------------------------------------------------------------------------------------


          Thanks,

          Zhe Wu
          • 2. Re: Problem loading data from jena
            725104
            Hi Wu, we have included your code in a java test ang got the same problem.

            Our installation is Oracle Database 11.2.0.1.0. Then we added the 'Semantic patch' 11_2_sem and followed the instructions to create a tablespace and the RDF/SEM network. Finally we create a model as [explained here|http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11828/sdo_rdf_concepts.htm#CHDEDFFA] .

            Some text in the exception is spanish; basically it seems to say 'fails inserting the literal value'... The rest of data in the app has been correctly inserted.

            This is the java test:

            public class PruebaOracleTest extends TestCase {

                 String jdbcUrl = "jdbc:oracle:thin:user/pass@server:1521:bd";

                 public void testInsertData() throws Exception {

                      Oracle oracle = new Oracle(jdbcUrl, null, null);
                      GraphOracleSem graph = new GraphOracleSem(oracle, "ARTICLES");
                      ModelOracleSem model = new ModelOracleSem(graph);

                      Model inMemoryJenaModel = ModelFactory.createDefaultModel();

                      long lStartTime = System.currentTimeMillis();
                      System.out.println("testCustomerMisc: start");
                      Triple t = new Triple(Node.createURI("http://sub"), Node
                                .createURI("http://www.w3.org/2003/01/geo/wgs84_pos#long"),
                                Node.createLiteral("-5.9278863", null,
                                          (RDFDatatype) XSDDatatype.XSDdouble));
                      graph.add(t);
                      graph.flushAdd();

                      String queryString = "SELECT * " + "WHERE { "
                                + " ?subject ?predicate ?object . " + "} ";

                      Query query = QueryFactory.create(queryString);
                      QueryExecution qexec = QueryExecutionFactory.create(query, model);
                      ResultSet results;
                      {
                           results = qexec.execSelect();
                           ResultSetFormatter.out(System.out, results, query);
                      }
                 }

                 public void testListTriples() throws Exception {

                      Oracle oracle = new Oracle(jdbcUrl, null, null);
                      GraphOracleSem graph = new GraphOracleSem(oracle, "ARTICLES");

                      int cont = 0;
                      ExtendedIterator it = graph.find(Triple.ANY);
                      while (it.hasNext() && cont<100) {
                           Triple t = (Triple) it.next();
                           System.out.println(t.toString());
                           cont++;
                      }

                      graph.close();
                      oracle.dispose();
                 }
                 
                 public void testCleanModel() throws Exception {

                      Oracle oracle = new Oracle(jdbcUrl, null, null);
                      GraphOracleSem graph = new GraphOracleSem(oracle, "ARTICLES");
                      ModelOracleSem model = new ModelOracleSem(graph);

                      model.removeAll();

                      graph.close();
                      oracle.dispose();
                 }

            }

            And this the exception we get:

            java.sql.SQLException: ORA-55303: Fallo en el constructor SDO_RDF_TRIPLE_S: Simple case: SQLERRM=ORA-55328: fallo al intentar insertar el valor literal "-5.9278863"^^<http://www.w3.org/2001/XMLSchema#double>
            ORA-06512: en "MDSYS.MD", línea 1723
            ORA-06512: en "MDSYS.MDERR", línea 17
            ORA-06512: en "MDSYS.SDO_RDF_TRIPLE_S", línea 211

                 at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
                 at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)
                 at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)
                 at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)
                 at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
                 at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
                 at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:205)
                 at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1008)
                 at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1307)
                 at oracle.jdbc.driver.OraclePreparedStatement.sendBatch(OraclePreparedStatement.java:3753)
                 at oracle.jdbc.driver.OraclePreparedStatementWrapper.sendBatch(OraclePreparedStatementWrapper.java:1140)
                 at oracle.spatial.rdf.client.jena.GraphOracleSem.flushAdd(GraphOracleSem.java:1219)
                 at org.fundacionctic.ogd.data.support.PruebaOracleTest.testInsertData(PruebaOracleTest.java:42)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:597)
                 at junit.framework.TestCase.runTest(TestCase.java:154)
                 at junit.framework.TestCase.runBare(TestCase.java:127)
                 at junit.framework.TestResult$1.protect(TestResult.java:106)
                 at junit.framework.TestResult.runProtected(TestResult.java:124)
                 at junit.framework.TestResult.run(TestResult.java:109)
                 at junit.framework.TestCase.run(TestCase.java:118)
                 at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
                 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
                 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
                 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
                 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
                 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
            • 3. Re: Problem loading data from jena
              alwu-Oracle
              Hi,

              It is a bit strange. I am guessing it is the NLS_LANG that is causing the difference.

              If you make the following change (replace the . with a comma in the double value), does the error go away?

              "-5.9278863"
              ==>
              "-5,9278863"

              Thanks,

              Zhe Wu
              • 4. Re: Problem loading data from jena
                725104
                You got it right. Replacing the point with comma did the trick. Is there any way of solving the problem by some db configuration?
                • 5. Re: Problem loading data from jena
                  alwu-Oracle
                  There are a few posts that may help.

                  ALTER SESSION NS_LANG

                  and

                  ORA-12705: Cannot access NLS data files or invalid environment specified (which mentions Locale setting)

                  Cheers,

                  Zhe Wu
                  • 6. Re: Problem loading data from jena
                    alwu-Oracle
                    You can try putting this in your Java code before you instantiate the Oracle object. Does it help?

                    Locale.setDefault(Locale.US);

                    Cheers,

                    Zhe Wu