My table has 3 operations 1) add 2) delete 3) update status. 

where 1 and 2 are Jbuttonsl

when I click 1)add a new row is added

when I click 2) delete the row is added.

1 and 2) are working as i set, but for updating status in last column, I coded in this way

```
public void statusUpd() throws SQLException
{
        table.getModel().addTableModelListener(new TableModelListener()
        {
            @Override
            public void tableChanged(TableModelEvent tme) 
            {
                int row = table.getSelectedRow();
                if(!(row<0))
                {
                    String name=(String)(table.getModel().getValueAt(row, 0));
                    String status = (String)(table.getModel().getValueAt(row, 3));
                    String update = "UPDATE "+deptName+ " SET Status = ? WHERE Name = ?";
                    try 
                    {
                        conn = ac.getConnection();
                        stmt = conn.prepareStatement(update);

                        stmt.setString(1, status);
                        stmt.setString(2, name);
                        stmt.executeUpdate();
                    } 
                    catch (SQLException | ClassNotFoundException ex)
                    {
                        ex.printStackTrace();                            
                    }
                    finally
                    {
                        try
                        {               
                            if(stmt != null){stmt.close();}
                            if(conn != null) {conn.close();}
                        }
                        catch(SQLException e){}
                     }
                }
            }
        });

}

```

But this method listens when the add or delete button is clicked, is there any way to avoid this?