• Post Reply Bookmark Topic Watch Topic
  • New Topic

ResultSet returns list  RSS feed

 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May i know how to make this resultset return list a table of 20 columns and many rows then i want to print through the table through list.

 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of putting all your data into a Map, create an Employee object (I assume this question is related to your other posts) for each row, populate it with the data and then add it to your list. You can then print out the data as explained in your other post.
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
may i know how to do? below mentioned code is not working properly

 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have a choice.

You can either create an Employee class that has a constructor that accepts all the database data as parameters. If you do this, then you will need to read all the data from a row of the database and then create a new Employee object using the data.

Alternatively, you can have an Employee class with a no arg constructor and a lot of setter methods. In this case you will create a new Employee object before you read each row and then use the appropriate setter method as you get each column from the row.

You could also do a combination of the two. Have a constructor that accepts (say ) a name as a parameter and then use setter methods for all the other data.
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joanne Neal:
You have a choice.

You can either create an Employee class that has a constructor that accepts all the database data as parameters. If you do this, then you will need to read all the data from a row of the database and then create a new Employee object using the data.

Alternatively, you can have an Employee class with a no arg constructor and a lot of setter methods. In this case you will create a new Employee object before you read each row and then use the appropriate setter method as you get each column from the row.

You could also do a combination of the two. Have a constructor that accepts (say ) a name as a parameter and then use setter methods for all the other data.


can you please check my previous code and suggest me some thing.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!