This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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:
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.
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.
Joined: Oct 13, 2005
Or, are you hanging up in the loop? Then you might only get one value at all.
Joined: Oct 04, 2007
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.