6 Replies Latest reply on Oct 7, 2008 8:47 PM by alwu-Oracle

    [Jena] Exception thrown with Jena Adaptor 2

    637657
      I am testing integration with Jena Adaptor 2 and am getting a couple exceptions that I didn't see with version 1. I am testing with Oracle 11.1.0.6 rdbms.

      1. Adding an OracleSemModel to a default Jena model:

      Model oraModel = ModelOracleSem.createOracleSemModel( oracle, oraModelName );
      Model m = ModelFactory.createDefaultModel();
      m.add(oraModel);

      The exception stack trace:

      0 [main] FATAL SimpleLog.fatal - next: exception
      java.sql.SQLException: Invalid column index
           at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
           at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
           at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227)
           at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:344)
           at oracle.spatial.rdf.client.jena.OracleSemIterator.getNodesFromResultSet(OracleSemIterator.java:414)
           at oracle.spatial.rdf.client.jena.OracleSemIterator.next(OracleSemIterator.java:315)
           at com.hp.hpl.jena.util.IteratorCollection.iteratorToList(IteratorCollection.java:52)
           at com.hp.hpl.jena.graph.impl.SimpleBulkUpdateHandler.addIterator(SimpleBulkUpdateHandler.java:57)
           at com.hp.hpl.jena.graph.impl.SimpleBulkUpdateHandler.add(SimpleBulkUpdateHandler.java:67)
           at com.hp.hpl.jena.rdf.model.impl.ModelCom.add(ModelCom.java:169)
           at com.hp.hpl.jena.rdf.model.impl.ModelCom.add(ModelCom.java:166)


      2. Deleting a model:

           GraphOracleSem graph = new GraphOracleSem( oracle, oraModelName );
           graph.dropTables();
           graph.close();

      The following exception is thrown:

      694891 [main] ERROR SimpleLog.error - Could not close Oracle connection
      java.sql.SQLException: ORA-00942: table or view does not exist
      ORA-06512: at "IX_SEM.ORACLE_ORARDF_GRANT", line 1
      ORA-06512: at line 1

           at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
           at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
           at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
           at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)
           at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:180)
           at oracle.jdbc.driver.T4CCallableStatement.execute_for_rows(T4CCallableStatement.java:783)
           at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1028)
           at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2888)
           at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:2979)
           at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4103)
           at oracle.spatial.rdf.client.jena.GraphOracleSem.invalidateCursor(GraphOracleSem.java:2639)
           at oracle.spatial.rdf.client.jena.GraphOracleSem.flushAdd(GraphOracleSem.java:1231)
           at oracle.spatial.rdf.client.jena.GraphOracleSem.close(GraphOracleSem.java:1152)
        • 1. Re: [Jena] Exception thrown with Jena Adaptor 2
          alwu-Oracle
          Hi,

          I just ran the following without any problem. Note that after dropTables()
          you no longer need to close the graph object. The underlying RDF/OWL
          model is dropped.


          void testAddModelToJenaModel(String jdbcUrl, String user, String password,
          String modelName, PrintStream psOut)
          throws SQLException, IOException
          {

          Oracle oracle = new Oracle( jdbcUrl, user, password );
          GraphOracleSem semGraph = new GraphOracleSem(oracle, modelName);
          ModelOracleSem semModel = new ModelOracleSem(semGraph);
          populateGraph(semGraph);


          Model m = ModelFactory.createDefaultModel();
          m.add(semModel);

          semGraph.dropTables();
          oracle.dispose();
          }
          1 person found this helpful
          • 2. Re: [Jena] Exception thrown with Jena Adaptor 2
            alwu-Oracle
            Forgot to ask, what is the diagnostic output when the exception happens?

            Try the following JVM properties in your command line.
            -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
            -Dorg.apache.commons.logging.simplelog.defaultlog=debug
            1 person found this helpful
            • 3. Re: [Jena] Exception thrown with Jena Adaptor 2
              637657
              Hi Alan,

              Your suggestion for deleting the model works. Awesome! Thanks.

              I am still seeing the problem when reading a model. Ah! Debugging (as you requested) reveals all...

              When saving a model the Jena Adaptor fails to create a table index because index identiifier is too long (my models have long names):

              [DEBUG] Oracle - executeUpdate: stmt = CREATE INDEX MTX_7992887020953526950_triple_idx ON "MTX_7992887020953526950_TPL"(
              to_char("TRIPLE".rdf_m_id, 'FMXXXXXXXXXXXXXXXX') ||'_'|| to_char("TRIPLE".rdf_s_id, 'FMXXXXXXXXXXXXXXXX') ||'_'|| t
              o_char("TRIPLE".rdf_p_id, 'FMXXXXXXXXXXXXXXXX') ||'_'|| to_char("TRIPLE".rdf_c_id, 'FMXXXXXXXXXXXXXXXX') ) NOLOGGING
              [DEBUG] GraphOracleSem - create index: exception <java.sql.SQLException: ORA-00972: identifier is too long
              java.sql.SQLException: ORA-00972: identifier is too long
                   at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
                   at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
                   at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
                   at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)
                   at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:112)
                   at oracle.jdbc.driver.T4CStatement.execute_for_rows(T4CStatement.java:474)
                   at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1028)
                   at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:1451)
                   at oracle.spatial.rdf.client.jena.Oracle.executeUpdate(Oracle.java:503)
                   at oracle.spatial.rdf.client.jena.GraphOracleSem.createTables(GraphOracleSem.java:1585)
                   at oracle.spatial.rdf.client.jena.GraphOracleSem.clearRepository(GraphOracleSem.java:1135)
                   at oracle.spatial.rdf.client.jena.OracleBulkUpdateHandler.removeAll(OracleBulkUpdateHandler.java:1395)
                   at com.hp.hpl.jena.rdf.model.impl.ModelCom.removeAll(ModelCom.java:314)

              The stack trace above is actually from trying to drop any existing triples before saving the model, hence removeAll() is called.
              Later when I read the model, I think the index that is supposed to be there is referenced hence, the exception:

              [FATAL] OracleSemIterator - next: exception <java.sql.SQLException: Invalid column index>java.sql.SQLException: Invalid
              column index
                   at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
                   at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
                   at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227)
                   at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:344)
                   at oracle.spatial.rdf.client.jena.OracleSemIterator.getNodesFromResultSet(OracleSemIterator.java:414)
                   at oracle.spatial.rdf.client.jena.OracleSemIterator.next(OracleSemIterator.java:315)
                   at com.hp.hpl.jena.util.IteratorCollection.iteratorToList(IteratorCollection.java:52)
                   at com.hp.hpl.jena.graph.impl.SimpleBulkUpdateHandler.addIterator(SimpleBulkUpdateHandler.java:57)
                   at com.hp.hpl.jena.graph.impl.SimpleBulkUpdateHandler.add(SimpleBulkUpdateHandler.java:67)
                   at com.hp.hpl.jena.rdf.model.impl.ModelCom.add(ModelCom.java:169)
                   at com.hp.hpl.jena.rdf.model.impl.ModelCom.add(ModelCom.java:166)

              Any suggestions? I'm afraid it might be tough to shorten my model names. Basically, I'm generating unique numbers that get mapped to URLs since URLs are invalid names for oracle models.
              • 4. Re: [Jena] Exception thrown with Jena Adaptor 2
                alwu-Oracle
                It is clear that the index name (derived based on model name) is a bit too long :)

                I know it is extra work for you to shorten the name. However, there is no other workaround.
                Could you use a simple mapping table to store URLs (for model names) ==> a short integer (sequence)?
                • 5. Re: [Jena] Exception thrown with Jena Adaptor 2
                  637657
                  OK, thanks Alan. Were application table indexes automatically added in version 1? I didn't run into this before version 2. I'm really not complaining; indexes are good :)
                  • 6. Re: [Jena] Exception thrown with Jena Adaptor 2
                    alwu-Oracle
                    Yes it is added in Jena Adaptor 1.

                    The reason is that Jena Adaptor, as a general API, has to provide good performance
                    when people are trying to remove triples. At least one index has to be there on
                    application table to make deletes fast.

                    Note that this additional index will slow down inserts. That is why in the code example, I
                    recommend dropping that index at the beginning of a large amount of data loading,
                    and then re-create it after loading is done.

                    I know you are not complaining. Thanks for understanding... :)

                    Cheers,

                    Zhe Wu (aka. Alan Wu)