Faire rechercher dans txtfield
Résolu
papillonlibre22
Messages postés
27
Date d'inscription
Statut
Membre
Dernière intervention
-
KX Messages postés 16761 Date d'inscription Statut Modérateur Dernière intervention -
KX Messages postés 16761 Date d'inscription Statut Modérateur Dernière intervention -
Bonjour, j'ai un probleme avec mon code quand je lance on m'affiche l’erreur suivant:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECTid,id_user,username,password,type FROM utilisateur' at line 1
Voici mon code:
ma fonction:
Merci pour voter aide!!
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECTid,id_user,username,password,type FROM utilisateur' at line 1
Voici mon code:
if(txtre.getText().equals("")){//si le txtfild es t vid le programme va afficher svp
JOptionPane.showMessageDialog(this,"SVP entrer quelque chose");
}else{
if(cmbre.getSelectedItem().equals("id_user")) {
r = db.querySelectAll("utilisateur", "id_user LIKE '%" + txtre.getText() + "%' ");
table_user.setModel(new ResultSetTableModel(r));
} else if(cmbre.getSelectedItem().equals("username")) {
r = db.querySelectAll("utilisateur", "username LIKE '%" + txtre.getText() + "%' ");
table_user.setModel(new ResultSetTableModel(r));
} else if(cmbre.getSelectedItem().equals("password")) {
r = db.querySelectAll("utilisateur", "password LIKE '%" + txtre.getText() + "%' ");
table_user.setModel(new ResultSetTableModel(r));
} else if(cmbre.getSelectedItem().equals("type")) {
r = db.querySelectAll("utilisateur", "type LIKE '%" + txtre.getText() + "%' ");
table_user.setModel(new ResultSetTableModel(r));
}
ma fonction:
public ResultSet querySelectAll(String nomTable){
connexionDatabase();
SQL = "SELECT * FROM " +nomTable;
return this.executionQuery(SQL);
}
Merci pour voter aide!!
A voir également:
- Faire rechercher dans txtfield
- Rechercher ou entrer l'adresse - Guide
- Rechercher image - Guide
- Rechercher remplacer word - Guide
- Rechercher une chanson - Guide
- Adresse IP locale : comment la trouver facilement - Guide
1 réponse
Bonjour,
C'est le même problème que dans ta conversation précédente, ta requête
C'est le même problème que dans ta conversation précédente, ta requête
SELECTid,id_userest fausse car il manque un espace après le SELECT.