10 Replies Latest reply: Aug 15, 2012 6:32 AM by 923096 RSS

    Error with jdbc: incorect sql type

    923096
      Hi,

      I try to use jdbc to get data using query :
      SELECT x grandfather, y grandchild
      FROM TABLE(SEM_MATCH(
      *'(?x :grandParentOf ?y) (?x rdf:type :Male)',*
      SEM_Models('family'),
      SEM_Rulebases('RDFS','family_rb'),
      SEM_ALIASES(SEM_ALIAS('','http://www.example.org/family/')),
      null));

      But I get error incorect sql type and it is about using ResultSet rs=stmt.executeQuery(query) where query is using query.
        • 1. Re: Error with jdbc: incorect sql type
          alwu-Oracle
          Hi,

          Could you please cut & paste here the JDBC code snippet you use to run the query and fetch results?
          Similar logic has been implemented in Jena Adapter without a problem.

          Thanks,

          Zhe Wu
          • 2. Re: Error with jdbc: incorect sql type
            923096
            Statement stmt;
                      try {
                           stmt = con.createStatement();
                           String res=null;
                           ResultSet rs=stmt.executeQuery("Select y FROM table (SEM_MATCH('(:Jack rdfs:subClassOf ?y) ',SEM_MODELS('family'),null,SEM_ALIASES(SEM_ALIAS('','http://www.example.org/family/')),null))");
                           
                           while(rs.next())
                           {
                           res=rs.getString("y");
                                
                           }
                           
                           rs.close();
                           stmt.close();

            Edited by: user8894354 on 2012-08-10 02:25
            • 3. Re: Error with jdbc: incorect sql type
              alwu-Oracle
              Hi,

              I can run this without a problem. Which version of database, Jena, Jena Adapter, and JDBC are you using?

              Thanks,

              Zhe

              Oracle oracle = new Oracle(jdbcUrl, user, password);
              ...
              GraphOracleSem g = (GraphOracleSem) modelDest.getGraph();

              // add a triple for test purpose
              Node sub = Node.createURI("http://www.example.org/family/Jack");
              Node pred = Node.createURI("http://www.w3.org/2000/01/rdf-schema#subClassOf");
              Node obj = Node.createURI("http://obj/C");
              Triple triple = Triple.create(sub, pred, obj);
              g.add(triple);
              g.commitTransaction();

              System.err.println("start");

              Statement stmt;
              try {
              stmt = oracle.getConnection().createStatement();
              String res=null;
              ResultSet rs=stmt.executeQuery("Select y FROM table (SEM_MATCH('(:Jack <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?y) ',SEM_MODELS('family'),null,SEM_ALIASES(SEM_ALIAS('','http://www.example.org/family/')),null,null,null))");

              while(rs.next()) {
              res=rs.getString("y");
              System.out.println(res);
              }
              ...

              ==>
              start
              http://obj/C
              • 4. Re: Error with jdbc: incorect sql type
                923096
                OK, I use Jena Adapter.

                Edited by: user8894354 on 2012-08-10 12:59
                • 5. Re: Error with jdbc: incorect sql type
                  alwu-Oracle
                  Hi,

                  Jena Adapter is recommended if you plan to write a Java application that uses Oracle Database
                  Semantic technologies.

                  Note however, in my example, I used Jena Adapter only to add a triple for testing purpose.

                  Thanks,

                  Zhe
                  • 6. Re: Error with jdbc: incorect sql type
                    923096
                    One more question: when I get data from database I should put their in all Node and then in Triple each time when I get data from database?
                    • 7. Re: Error with jdbc: incorect sql type
                      alwu-Oracle
                      Hi,

                      Please take a look at Example 7-15 of Section 7.15.1 of the following document.
                      http://docs.oracle.com/cd/E11882_01/appdev.112/e11828/sem_jena.htm#CBBCIJAD

                      Hope it helps,

                      Zhe Wu
                      • 8. Re: Error with jdbc: incorect sql type
                        923096
                        Can I use SEM_MATCH with Jena Adapter (not clear SPARQL)?

                        Edited by: user8894354 on 2012-08-11 12:34
                        • 9. Re: Error with jdbc: incorect sql type
                          alwu-Oracle
                          Yes you can. From an Oracle instance, you can get the underlying DB connection instance.

                          oracle.getConnection();

                          Hope it helps,

                          Zhe Wu
                          • 10. Re: Error with jdbc: incorect sql type
                            923096
                            OK, thanks. You very help me!

                            Edited by: user8894354 on 2012-08-15 04:32