3 Replies Latest reply on Jan 29, 2010 3:51 PM by 715399

    Check model existence in Oracle11g

    714977
      How can I check the model existence in Oracle11g using jena adapter 2.
      I want my application to display specific error message if the model is not exists in the database.

      For example I already have Cardiovascular and Pediatric model in the database.
      But when I want to query for other model i.e. OccupationalHealth my application will automatically create the OccupationalHealth model and its related table(s) . My question is how can I control the auto creation of model in Oracle 11g using jena adapter 2 library?

      Code sinppet :
      GraphOracleSem graph = null;
      ModelOracleSem modelSem = null;
      ResultSet newResultSet = null;
      QueryExecution qexec = null;

      graph = new GraphOracleSem(oracleConn, "Cardiovascular");
      modelSem = new ModelOracleSem(graph);

      qexec = QueryExecutionFactory.create(QueryFactory.create(query),
                               model);
      resultSet = qexec.execSelect();


      Your help is much appreciated.

      Yours tryly,
      NLia
        • 1. Re: Check model existence in Oracle11g
          715399
          Hi NLia,

          You might want to look at the OracleUtils.getAllReadableModels(Oracle oracle) function. It returns a list of all the models readable by the user who established the Oracle session.

          Cheers,
          Vladimir
          • 2. Re: Check model existence in Oracle11g
            714977
            Hi Vladimir,
            Thanks for your reply.
            Which version of Oracle Jena Adapter you were using?
            I'm using Jena Adapter 2 and the function that you referred to is not exist.


            Regards,
            NLia
            • 3. Re: Check model existence in Oracle11g
              715399
              Hi NLia,

              I see. OracleUtils.getAllReadableModels is available in the latest version of the Jena Adaptor (11.2). I suggest upgrading your database and the Jena Adaptor version if possible, since it contains many new features and optimizations.

              One alternative is to query the semantic model views directly from your Java application. This statement: "SELECT 1 FROM MDSYS.SEM_MODEL$ WHERE MODEL_NAME=?" should do the trick. Please consult the official documentation for more information on the MDSYS.SEM_MODEL$ view.

              Cheers,
              Vladimir