the same code as following does not work
What does that mean?
Does it mean:
a) the TableModel is empty?
b) the table doesn't appear on the GUI?
c) something else?
Generally to it is better to create a new TableModel and then just use table.setModel(...) to refresh a visible table.