JBuilder, 1, JBuilder Advanced Database Concepts: Query Notes

By: Borland Staff

Abstract: JBuilder Advanced Database Concepts: Query Notes

JBuilder Advanced Database Concepts: Query Notes

    There are many way to do queries in JBuilder.  For this example, the technique used was:

      try{ 
      QueryDataSet q = pqDM1.getDataModule(); 
      ... 
      load parameters 
      .... 
      q.open() 
      q.executeQuery(); 
      ... 
      checking results 
      ... 
      q.close(); 
      }catch (Exception x){ 
       System.err.println(x); 

    The above query will ensure that each time the query is executed, the new parameters are in place.  If you don't have the executeQuery() method, the result set will not get reset upon re-entrance to this method.  Also, if you only have the open() method the first time you run the query it will work, however subsequent runs will fail.  Since this technique closes the QueryDataSet at the end of the process, you must call the open() method upon re-entrance of the query.  Another way to do the query is as follows: 

      try{ 
      QueryDataSet q = pqDM1.getDataModule(); 
      ... 
      load parameters 
      .... 
      q.open() 
      q.refresh(); 
      ... 
      checking results 
      ... 
      q.close(); 
      }catch (Exception x){ 
       System.err.println(x); 

    The same rules apply as above.  The JBuilder help seems to like the refresh() method over the executeQuery() method.  I have found no difference in the methods. 

Return to Step 6: Add the code.

Server Response from: ETNASC04