Hi guys!

I have a JTable updated from MySQL. I can successfully insert a row in JTable using SQL statement "insert into...". However, when I execute a delete statement, then JTable is not updated. Please, help me to find an error.

public void actionPerformed(java.awt.event.ActionEvent evt) {
                SystClasses.FilterClass.tableModel.initDB("85.254.219.164", "employee_record", "liana", "liana1982");
                int id = tableDetails.getSelectedRow()+1;

                SystClasses.FilterClass.tableModel.setQueryDelete("delete from employee where id ='"+id+"'");
                SystClasses.FilterClass.tableModel.closeDB();
  }

  public void setQueryDelete(String q) {
    try {
      // Execute the query and store the result set and its metadata
      int rs = statement.executeUpdate(q);

      fireTableChanged(null); // notify everyone that we have a new table.
      } catch (Exception e) {
      cache = new Vector(); // blank it out and keep going.
      System.out.println(e.getMessage());
    }
  }

I solved the problem. Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.