title: JProgressBar SQL Query
body: <p>Since one week now, I am looking for how to make <code>JProgressBar</code> to a result set. Could you give me, please, an example a sample code of a progress bar applied on a result set? </p>
  
  <p>This a sample code with a button and the action done by clicking on it.</p>
  
  <pre><code>JButton btnRechercher = new JButton("Rechercher");
      btnRechercher.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
              Connection conn = ConnectionManager.getInstance().getConnection();
              try {
                  String sql = "SELECT id, nom, prenom, niveau, localisation, pays, secteur1 FROM infos WHERE (niveau LIKE ? AND  localisation LIKE ? AND pays LIKE ? AND secteur1 LIKE ?) OR (MATCH (titre_cv1, titre_cv2, titre_cv3) AGAINST (? IN BOOLEAN MODE))";
  
                  PreparedStatement stmt = conn.prepareStatement(sql);
                  stmt.setObject(1, ""+comboNiveau.getSelectedItem()+"");
                  stmt.setObject(2, ""+comboLocal.getSelectedItem()+"");
                  stmt.setObject(3, ""+comboPays.getSelectedItem()+"");
                  stmt.setObject(4, ""+comboSecteur.getSelectedItem()+"");
                  stmt.setString(5, ""+motCle.getText()+"");
  
                  ResultSet rs = stmt.executeQuery();
  
                  DefaultTableModel model = new DefaultTableModel();
                  model.setColumnIdentifiers(new String []{"id","nom","prenom","niveau","localisation","pays","secteur1"}); 
                      while (rs.next()) {
                          model.addRow(new Object[]{rs.getObject("id"),rs.getObject("nom"),rs.getObject("prenom"),rs.getObject("niveau"),rs.getObject("localisation"),rs.getObject("pays"),rs.getObject("secteur1")});
                      }
                      table.setModel(model);
              } catch (Exception e1) {
                  System.err.println(e1);
              }
              ConnectionManager.getInstance().close();
          }
      });
  </code></pre>
  
  <p>I add that :</p>
  
  <pre><code>class ThreadAvanceBarre extends Thread {
  
          public ThreadAvanceBarre(JProgressBar ProgressBar){     
          }
  
          public void run(){
          try {
              Connection conn = ConnectionManager.getInstance().getConnection();
  
              String sql = "SELECT id, nom, prenom, niveau, localisation, pays, secteur1 FROM infos WHERE (niveau LIKE ? AND  localisation LIKE ? AND pays LIKE ? AND secteur1 LIKE ?) OR (MATCH (titre_cv1, titre_cv2, titre_cv3) AGAINST (? IN BOOLEAN MODE))";
  
              PreparedStatement stmt = conn.prepareStatement(sql);
              stmt.setObject(1, ""+comboNiveau.getSelectedItem()+"");
              stmt.setObject(2, ""+comboLocal.getSelectedItem()+"");
              stmt.setObject(3, ""+comboPays.getSelectedItem()+"");
              stmt.setObject(4, ""+comboSecteur.getSelectedItem()+"");
              stmt.setString(5, ""+motCle.getText()+"");
              ResultSet rs = stmt.executeQuery();
              DefaultTableModel model = new DefaultTableModel();
              model.setColumnIdentifiers(new String []{"id","nom","prenom","niveau","localisation","pays","secteur1"}); 
              while (rs.next()) {
                  model.addRow(new Object[]{rs.getObject("id"),rs.getObject("nom"),rs.getObject("prenom"),rs.getObject("niveau"),rs.getObject("localisation"),rs.getObject("pays"),rs.getObject("secteur1")});
              }
              table.setModel(model);
          } catch (Exception e1) {
              System.err.println(e1);
          }
          ConnectionManager.getInstance().close();
      }
  }
  </code></pre>