Dans mon projet de gestion de la paie des employés, le champ de texte de recherche ne fonctionne pas .. j'utilise mysql workbench et java .. ne renvoie aucune valeur .. Comment puis-je résoudre cette erreur ? Comment fonctionne mon champ de recherche?La zone de texte de recherche ne renvoie aucune valeur
Mon codage est ici:
enter code here
private void txt_searchKeyReleased(java.awt.event.KeyEvent evt) {
try{
String sql ="select * from Staff_information where id=? ";
pst=conn.prepareStatement(sql);
pst.setString(1,txt_search.getText());
rs=pst.executeQuery();
String add1 =rs.getString("id");
txt_id.setText(add1);
String add2 =rs.getString("first_name");
txt_firstname.setText(add2);
String add3 =rs.getString("surname");
txt_surname.setText(add3);
String add4 =rs.getString("Dob");
txt_dob.setText(add4);
String add5 =rs.getString("Email");
txt_email.setText(add5);
String add6 =rs.getString("Telephone");
txt_tel.setText(add6);
String add7 =rs.getString("Address");
txt_address.setText(add7);
String add8 =rs.getString("Department");
txt_dep.setText(add8);
String add10 =rs.getString("Salary");
txt_salary.setText(add10);
String add11 =rs.getString("Address2");
txt_add2.setText(add11);
String add12 =rs.getString("Apartment");
txt_apt.setText(add12);
String add13 =rs.getString("Post_code");
txt_pc.setText(add13);
String add14 =rs.getString("Status");
txt_status.setText(add14);
String add15 =rs.getString("Date_hired");
txt_doj.setText(add15);
String add16 =rs.getString("job_title");
txt_job.setText(add16);
String add17 =rs.getString("Designation");
txt_design.setText(add17);
byte[] image = rs.getBytes("Image");
ImageIcon imageIcon = new ImageIcon(new ImageIcon(image).getImage().getScaledInstance(img.getWidth(), img.getHeight(), Image.SCALE_SMOOTH));
img.setIcon(imageIcon);
}catch(Exception e){
} finally {
try{
rs.close();
pst.close();
} catch(Exception e){
} }
Je ne comprends pas votre réponse .. –
J'ai mis à jour ma réponse - voir les deux premiers paragraphes. J'espère que cela aide. – anacron
Voir la 7ème ligne dans mon fragment de code qui contient 'rs.next()'. – anacron