ArrayList of Objects size() incorrect.?.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Kevin_Baker
Posted On:   Friday, May 17, 2002 02:17 AM

I'm storing a db resultset in an ArrayList of custom objects with in a method. The method is populating the ArrayList by moving through the rs.next() The size of the ArrayList comes back as number of records * number of properties in my object. Any ideas? ::::::::::::::: Code :::::::::::: Collection collection = new ArrayList(); while(rs.next()) { gdoUser userObject = new gdoUser(); userObject.setDirectoryId(rs.getInt("directoryId")); userObject.setCN(rs.getString("CN")); userObject.setUID(rs.getString("UID")); userObject.setDirectoryPassword(rs.getString("password")); userObject.setGivenName(rs.getString("   More>>

I'm storing a db resultset in an ArrayList of custom objects with in a method.

The method is populating the ArrayList by moving through the rs.next()

The size of the ArrayList comes back as number of records * number of properties in my object. Any ideas?


::::::::::::::: Code ::::::::::::
Collection collection = new ArrayList();
while(rs.next())
{
gdoUser userObject = new gdoUser();
userObject.setDirectoryId(rs.getInt("directoryId"));
userObject.setCN(rs.getString("CN"));
userObject.setUID(rs.getString("UID"));
userObject.setDirectoryPassword(rs.getString("password"));
userObject.setGivenName(rs.getString("givenName"));
userObject.setSurName(rs.getString("SN"));
userObject.setEmail(rs.getString("email"));
collection.add(userObject);
}

   <<Less

Re: ArrayList of Objects size() incorrect.?.

Posted By:   Simon_Ablett  
Posted On:   Friday, May 17, 2002 07:56 AM

Your code looks ok, I think, although it is a little hard to read. When you post code examples could you please place it inside '
' and '
' tags. Are you sure that the result-set is returning the number of rows you think it should? Have you tried iterating through the collection and looking at what has actually been stored there?

Regards.
About | Sitemap | Contact