ResultSet rs = statment.executeQuery();
table.setModel(DbUtils.resultSetToTableModel(rs));
I think you cannot set column names which are selected from a database, but you can copy data out of that column in a new column and set the name of that new column.
Or else you can get that column name using this code.. :)
ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM TABLE2");
ResultSetMetaData rsmd = rs.getMetaData();
String name = rsmd.getColumnName(1);
Where 1
is the index of the column.