ResultSet to Collection

Discussions

General J2EE: ResultSet to Collection

  1. ResultSet to Collection (3 messages)

    I would like to find a simply way to copy all data in a ResultSet into the server's memory. And this way should be generic enough to handle whatever the ResultSet contains.

    I wonder if there is any open-source library/class package that provides method to fetch all data from a ResultSet object and automatically put everything into a Collection object?

    Threaded Messages (3)

  2. ResultSet to Collection[ Go to top ]

    create a method that takes in the result and uses the meta data and rows to create the Collection its not hard
  3. ResultSet to Collection[ Go to top ]

    ResultSet rs = // Load result set ...
    ResultSetMetaData rsmd = rs.getMetaData();
    int numColumns = rsmd.getColumnCount();
    List rows = new LinkedList();
    while (rs.next()) {
      List columns = new LinkedList();
      for (int i=1; i<=numColumns; i++) {
        columns.add(rs.getString(i));
      }
      rows.add(columns);
    }
  4. ResultSet to Collection[ Go to top ]

    ah~~ seems much simplier than I thought. I will try it then. Thx alot~~