code: public synchronized QueryResult execute() throws QueryException, InterruptedException {
          // create query string
          String queryString = query.getText();
          System.out.println("queryString = " + queryString);
  
          // count statement
          String countQueryString = "SELECT COUNT(*) FROM (" + queryString + ")";
  
  
          // set query's input wrapper
          synchronized (inputWrapper) {
              try {
                  inputWrapper.statement = conn.createStatement();
              } catch (SQLException e) {
                  e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                  return null;
              }
              inputWrapper.query = queryString;
              try {
                  inputWrapper.countStatement = conn.createStatement();
              } catch (SQLException e) {
                  e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                  return null;
              }
              inputWrapper.countQuery = countQueryString;
              inputWrapper.pending = true;
              inputWrapper.notify();
          }
  
          synchronized (resultWrapper) {
              try {
                  // wait for the query to complete
                  while (!resultWrapper.serviced) {
                      resultWrapper.wait();
                  }
                  if (resultWrapper.exception != null) {
                      throw resultWrapper.exception;
                  }
              } catch (InterruptedException e) {
                  cancel();
                  throw e;
              } finally {
                  resultWrapper.serviced = false;
              }
  
              return new QueryResult(resultWrapper.resultSet, resultWrapper.count, resultWrapper.executeTime);
          }
      }
docs: Execute the query.