Bases de donnees java

Résolu
Signaler
Messages postés
75
Date d'inscription
lundi 19 janvier 2009
Statut
Membre
Dernière intervention
31 mars 2009
-
Messages postés
15814
Date d'inscription
jeudi 8 août 2002
Statut
Modérateur
Dernière intervention
4 mars 2013
-
bonjour a tous je debute en java et souhaite supprimer un enregistrement de ma table voici l erreur generee:
Result Set not updatable.This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, can not use functions and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, can not use functions and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.

et voici mon code:

private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {Class.forName("com.mysql.jdbc.Driver");
url="jdbc:mysql://localhost/mabase";
con = DriverManager.getConnection(url, "root", "stockaj");
pr con.prepareStatement("SELECT nom AS n, email AS e, prenom AS p, pass AS p1 FROM mabase.identif WHERE (matricule'"+jTextField6.getText()+"')ORDER BY n DESC");
rec=pr.executeQuery();
rec.deleteRow();

pr.executeUpdate();
}
catch(SQLException ex){System.out.println("SQL Error:" + ex.getMessage());}
catch(ClassNotFoundException cnfe){
System.out.println(cnfe.getMessage());
}
}

Merci de me repondre!!!!

1 réponse

Messages postés
15814
Date d'inscription
jeudi 8 août 2002
Statut
Modérateur
Dernière intervention
4 mars 2013
130
Salut,

Exécute directement une requête DELETE, ca ira bien plus vite :
con.execute("DELETE FROM mabase.identif WHERE (matricule
='"+jTextField6.getText()+"')");

Et si tu ne veux supprimer que le premier :
con.execute("DELETE FROM mabase.identif WHERE (matricule= '"+jTextField6.getText()+"') limit 1");

______________________________________
DarK Sidious