<br><br>
List list = null;<br>
try {<br>
list = Collections.synchronizedList(new LinkedList());<br>
User user = null;<br>
CompositeEntity composite = new CompositeEntity();<br>
while(rs.next()) {<br>
user = composite.getUserVO();<br>
user.setId(rs.getInt("id"));<br>
user.setUsername(rs.getString("username"));<br>
user.setPassword(rs.getString("password"));<br>
user.setName(rs.getString("name"));<br>
user.setEmail(rs.getString("email"));<br>
user.setType(rs.getString("type"));<br>
user.setStatus(rs.getInt("status"));<br>
user.setTime(rs.getLong("time"));<br>
list.add(user);<br>
}
pstmnt.close();<br>
pstmnt = null;<br>
} catch(SQLException sqle) {<br>
throw new ChainedException(sqle, "HsqlUserDAO: rs.next(): " + sqle.getMessage());<br>
}<br>
return list;<br><br><br>
But, if you do, there it is:
Micael
At 05:49 PM 9/5/2003 -0500, you 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,
Matt
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
LEGAL NOTICE
This electronic mail transmission and any accompanying documents contain information belonging to the sender which may be confidential and legally privileged. This information is intended only for the use of the individual or entity to whom this electronic mail transmission was sent as indicated above. If you are not the intended recipient, any disclosure, copying, distribution, or action taken in reliance on the contents of the information contained in this transmission is strictly prohibited. If you have received this transmission in error, please delete the message. Thank you
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]