This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

deleting row from jTable

nadia ghezaiel
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • 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

Rob Spoor
Posts: 20495
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic