• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

deleting row from jTable

Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please i need help!!!

I write this code and it run correctly but without deletting any row from jTable!!!I will be crazy!!!

the code is :

JTable tableau;
public void supprimerCompte(JTable tableau){

try {

int lign= tableau.getSelectedRow();

Statement stmt = C.createStatement();

stmt.executeUpdate("DELETE FROM Compte WHERE Indice ="+lign);
System.out.println("voila c'est fait");
tableau.removeRowSelectionInterval(lign, lign);
catch (SQLException ex) {

System.out.println("Erreur de suppression du compte.");


And :
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
ConnPorCreationCompte C = new ConnPorCreationCompte();



After runnig I foud this result: "voila c'est fait"

Please I don't know were is the pb!!!
Please i need help,Please

Posts: 22784
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see any code that removes anything from the JTable. You remove the record from the database, then call tableau.removeRowSelectionInterval(lign, lign); which only de-selects the row. It doesn't remove anything.

To remove a row from a JTable you should use a TableModel that supports removal (like DefaultTableModel) and remove the row from it.
Or we might never have existed at all. Freaky. So we should cherish everything. Even this tiny ad:
a bit of art, as a gift, the permaculture playing cards
    Bookmark Topic Watch Topic
  • New Topic