Table how to clear data

How do I clear all data from the table and put new data in it…
Just like a new table… withouth column and data row… ?
Please help :frowning:

table.setContainerDataSource(new BeanItemContainer<Object>(Object.class));

Hello sir…
I havent use data source…
my goal is I want to make the table be fresh again…
So it means that the header and data should be removed…
I tried table.clear();
but when the new data comes… the previous header and data will be merge to the new data… instead it should be replaced with the new data…

Show your code.

                        System.out.println("Connecting to databse...");
                        conn = DriverManager.getConnection(DB_URL,"root","");

                        System.out.println("Creating statement...");
                        stmt = conn.createStatement();
                        String sql;
                        sql = textField.getValue();
                        ResultSet rs = stmt.executeQuery(sql);
                        ResultSetMetaData rsmd = rs.getMetaData();
                        for(int i=1; i<=rsmd.getColumnCount(); i++) {
                            table.addContainerProperty(rsmd.getColumnName(i), String.class, null);
                        int count = 0;
                        while( {
                            Object tableData[] = new Object[rsmd.getColumnCount()]
                            for(int i=0; i<rsmd.getColumnCount(); i++) {
 = rs.getString(rsmd.getColumnName(i+1));
                            table.addItem(tableData, new Integer(count) );

I think, that the easiest way is:

List props = new ArrayList(getContainerPropertyIds());
for(Object prop: props){

Wow… thanks for your help sir… :slight_smile:
It help me … :slight_smile: … thank you…

table.removeAllItems(); //removes all data in the table except column headers/titles