problem in passing while loop variables from database
preethi Ayyappan
Ranch Hand
Joined: Oct 04, 2007
Posts: 518
posted
0
Hi,
I am getting records from the database and store it in a string variable inside while loop.When i tried to access the variable in another class,i am getting the top most record saved inside the while loop
my code follows:
class1:
class 2:
Actually the records in the database contains aircel and airtel.But when i run this code, i am getting only aircel.
How can i get all the records taken from the database.please assist me to do this.
Thanks
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
4
posted
0
Are you always updating the same String? In which case you lose the previous value every time you traverse the loop. Try adding the Strings to a List<String> and return that List.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
4
posted
0
Or, are you hanging up in the loop? Then you might only get one value at all.
preethi Ayyappan
Ranch Hand
Joined: Oct 04, 2007
Posts: 518
posted
0
When i run the class1 alone without calling class2,i can able to get all the records from the database.But if i call class2 from class1 and tried to access the variable campaign1 from class1,it just prints the top most record.