« Return to Thread: JESS and JAVA

Re: JESS: JESS and JAVA

by Ksawi :: Rate this Message:

Reply to Author | View in Thread

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hello!


You can define query:


(defquery printStudents

       (Student (name ?x) (age ?y)))

To define it from Java you need to execute the following code:


rete.eval("(defquery printStudents (Student (name ?x) (age ?y)))"));


Now you have to execute the query:


QueryResult qs = rete.runQueryStar("printStudents", new ValueVector());


and then you can print the result in Java console:


System.out.println("The students are:        name        age");

while(result.next())

{

       try 

       {

               System.out.println("\t\t" + result.getString("x") + "\t" + result.getString("y"));

       } catch (JessException e) 

       {

                       e.printStackTrace();

       }

}


That's all. It should works.


-- 

Best regards,

 Jaroslaw Bak, http://www.put.poznan.pl

 « Return to Thread: JESS and JAVA