code: public static List<Column> getColumns(DatabaseMetaData metadata, String tableName) throws Exception {
          List<Column> columns = new ArrayList<Column>();
  
          PreparedStatement stmt = metadata.getConnection().prepareStatement("SELECT * FROM " + tableName);
          ResultSetMetaData rsmeta = stmt.getMetaData();
          for (int i = 1, ii = rsmeta.getColumnCount(); i <= ii; ++i) {
              columns.add(new Column(rsmeta, i));
          }
          stmt.close();
          return columns;
      }
docs: Returns a table's columns