I think you can use RowSet to wrap a ResultSet, and RowSet has a toCollection or getCollection method. (Or just don't user ResultSet at all, just use RowSet, Sun has "default" implementation in JDC, but Orcale has an extra download, other do to).
Worst case you write your own helper object.
But... I would use a DAO layer(and not code to JDBC), it will be cheaper/faster in the long run.
Consider writing a console generator (I have one, in CVS at bP for iBatis that jsut enmerates all tables in DB) that takes a SQL Strings[] in XML file, and based on that queries the DB, and writes a real DAO and beans (and can do this anytime, for any of your projects). (I do not know how well Hibernate works with SQL).
.V
Matt Raible wrote:
Dear Struts Experts,
I recently started a new project where most of the backend code is already written with JDBC and ResultSets. The ResultSets are iterated through and a POJOs values are set using pojo.setName(rs.getString("...")), etc. - you get the point. I'm wondering if there's an easier way - so I could do something like this:
ResultSet rs = stmt.executeQuery("SELECT ..."); List objects = FancyUtilitity.convertResultSetToListOfObjects(rs, object.class);
Hibernate let me do this very simply - and I miss the fact that I could type
a line or two to get a List of POJOs.
List users = ses.createQuery("from u in class " + User.class + "order by u.name").list();
I've looked at the RowSetDynaClass (http://tinyurl.com/mekh), which has an interesting way of doing this - is this the "recommended" approach in the JDBC world? Here's an example using it:
ResultSet rs = stmt.executeQuery("SELECT ..."); RowSetDynaClass rsdc = new RowSetDynaClass(rs); rs.close(); stmt.close(); ...; // Return connection to pool List rows = rsdc.getRows(); ...; // Process the rows as desired
Thanks,
M
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]