I’m new to Java and just getting into querying databases. So far I have my results in a ResultSetMetaData. I’m think that for each row in the dataset I should add it to some form of collection? Can anyone tell me the best practice for this?
Thanks,
Jonesy
Usually we have a class with fields that correspond to a table. Then, whenever we have a (full) row in a result set, we create an instance of this class.
Example:
Consider a table created like this:
A model class would be like this:
Now if you read data and have a ResultSet, you would create a new customer object and set the fields: