Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questiontry[ String requete ="select * from projet where titre='"+pjrtache1.getSelectedItem().toString()+"'"; System.out.println(requete); ResultSet rs =con.createStatement().executeQuery(requete); if (rs.next()) { System.out.println(rs.getString("titre")); i=rs.getInt("cod_prj"); String requete1 ="select * from tache where cod_prj='"+i+"'"; System.out.println(requete1); ResultSet rs1 =con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY).executeQuery(requete1); if(rs1.next()){ listache.removeAllItem(); while (rs1.next()) { System.out.println(rs1.getString("contenu")); listache.addItem(rs1.getString("titre")); }} }}}catch(SQLException e){ e.printStackTrace();}}
try{ listache.removeAllItem(); String requete ="select * from projet where titre='"+pjrtache1.getSelectedItem().toString()+"'"; System.out.println(requete); ResultSet rs =con.createStatement().executeQuery(requete); if (rs.next()) { System.out.println(rs.getString("titre")); i=rs.getInt("cod_prj"); String requete1 ="select * from tache where cod_prj='"+i+"'"; System.out.println(requete1); ResultSet rs1 =con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY).executeQuery(requete1); if(rs1.next()){ while (rs1.next()) { System.out.println(rs1.getString("contenu")); listache.addItem(rs1.getString("titre")); }} }}}catch(SQLException e){ e.printStackTrace();}}
try{ listache.removeAllItem(); String requete ="select tache.contenu, tache.titre from tache inner join projet ON projet.cod_prj = tache.cod_prj where projet.titre='"+pjrtache1.getSelectedItem().toString()+"'"; System.out.println(requete); ResultSet rs =con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY).executeQuery(requete); while(rs.next()) { System.out.println(rs.getString("contenu")); listache.addItem(rs.getString("titre")); }} } }catch(SQLException e){ e.printStackTrace(); } }
//button pour acces a cette espace ou il ya les 2 jcombobox et un button enregistrer public void modiftacheActionPerformed(ActionEvent evt) { System.out.println("modiftache.actionPerformed, event="+evt); System.out.println("suptache.actionPerformed, event="+evt); listache.removeAllItems(); cont.setText(""); contn.setText(""); crétache.setVisible(false); modif_tache.setVisible(true); jPanel1.setVisible(false); vistache.setVisible(true); String requete ="SELECT * FROM modul WHERE cod_ens='"+tab1[0].toString()+"'"; System.out.println(requete); try { java.sql.ResultSet rs = con.createStatement().executeQuery(requete); if(rs.next()) { int n=rs.getInt("cod_mod"); // System.out.println(n); System.out.println("l'enregisterement est trouvé"); String reqte="SELECT* FROM projet WHERE cod_mod='"+n+"'"; ResultSet rs1=(ResultSet) con.createStatement().executeQuery(reqte); pjrtache1.removeAllItems(); while (rs1.next()) { System.out.println(rs1.getString("titre")); pjrtache1.addItem(rs1.getString("titre")); } }}catch(Exception e){ e.printStackTrace();} } //remplir le dexiem combobox avec la jointure ds 2 table projet et tache public void pjrtache1ItemStateChanged(ItemEvent evt) { System.out.println("remplirpjr itemStateChanged, event="+evt); try{ String requete ="select tache.contenu, tache.titre from tache inner join projet ON projet.cod_prj = tache.cod_prj where projet.titre='"+pjrtache1.getSelectedItem()+"'"; System.out.println(requete); ResultSet rs =con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY).executeQuery(requete); listache.removeAllItems(); while(rs.next()) { System.out.println(rs.getString("contenu")); listache.addItem(rs.getString("titre")); } } catch(SQLException e){ JOptionPane.showMessageDialog(null, " Le projet selectionné ne contient pas des taches ", "SUPPRIMER",JOptionPane.INFORMATION_MESSAGE) ; e.printStackTrace(); } } /*l'erreur pour chaque selection d'un element afficher leur information le contenu et .... /* public void listacheItemStateChanged(ItemEvent evt) throws SQLException { System.out.println("listtache.itemStateChanged, event="+evt); ----> l'erreur java.lang.nullpointerexeption if(listache.getSelectedItem().equals("")) { JOptionPane.showMessageDialog(null, " la liste des taches est vide !! ", "ERREUR",JOptionPane.ERROR_MESSAGE) ; vistache.setVisible(false);} else{ String requete1 ="select * from tache where titre='"+listache.getSelectedItem()+"'"; System.out.println(requete1); ResultSet rs1 = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY).executeQuery(requete1); if(rs1.next()) { x=rs1.getInt("cod_tache"); contn.setText(rs1.getString("contenu")); cont.setText(rs1.getString("titre"));} }} }
public void listacheItemStateChanged(ItemEvent evt) throws SQLException { if (evt.getStateChange() == ItemEvent.SELECTED) { // faire la suite... } }
public void listacheItemStateChanged(ItemEvent evt) throws SQLException { if (evt.getStateChange() == ItemEvent.SELECTED) { { String requete1 ="select * from tache where titre='"+listache.getSelectedItem()+"'"; System.out.println(requete1); try{ ResultSet rs1 = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY).executeQuery(requete1); if(rs1.next()) { x=rs1.getInt("cod_tache"); contn.setText.getString("contenu")); cont.setText(rs1.getString("titre")); System.out.println(contn.getText()); System.out.println(cont.getText()); } else { JOptionPane.showMessageDialog(null, " le projet selectioneé ne contient pas des taches !! ", "ERREUR",JOptionPane.ERROR_MESSAGE) ; } }catch(SQLException ex){ ex.printStackTrace(); }} else { JOptionPane.showMessageDialog(null, " la liste des taches est vide !! ", "ERREUR",JOptionPane.ERROR_MESSAGE) ; vistache.setVisible(false); }} } }