Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in retrieving data and store it in string

 
Micheal John
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am running an application in tomcat 5.0. I have used the following coding for retreving the data from db and store it in string:



The above coding worked properly. I have added one new employee and the above code is not working and in the tomcat console it's just hacked. I have copied that below. If i am deleting the added user,then the application is working. What will be problem???

From TOmcat Console
[CONSOLE]
sql ::SELECT EMPLOYEEID,EMPLOYEENAME FROM EMPLOYEEINFO WHERE ACTIVATIONSTATUS='Y
' AND EMPLOYEEGRADE LIKE 'E%' ORDER BY EMPLOYEENAME
in while EmployeeInfo ::-Select-~-Select-
in while EmployeeInfo ::-Select-~-Select-^6000~Mukesh Ambani
in while EmployeeInfo ::-Select-~-Select-^6000~Mukesh Ambani^6001~Tom
in while EmployeeInfo ::-Select-~-Select-^6000~Mukesh Ambani^6001~Tom^9000~anil
kumar
in while EmployeeInfo ::-Select-~-Select-^6000~Mukesh Ambani^6001~Tom^9000~anil
kumar^1000~asdad
in while EmployeeInfo ::-Select-~-Select-^6000~Mukesh Ambani^6001~Tom^9000~anil
kumar^1000~asdad^9002~ganesh
in while EmployeeInfo ::-Select-~-Select-^6000~Mukesh Ambani^6001~Tom^9000~anil
kumar^1000~asdad^9002~ganesh^9001~hari
in while EmployeeInfo ::-Select-~-Select-^6000~Mukesh Ambani^6001~Tom^9000~anil
kumar^1000~asdad^9002~ganesh^9001~hari^6002~jack
in while EmployeeInfo ::-Select-~-Select-^6000~Mukesh Ambani^6001~Tom^9000~anil
kumar^1000~asdad^9002~ganesh^9001~hari^6002~jack^7878~pete
in while EmployeeInfo ::-Select-~-Select-^6000~Mukesh Ambani^6001~Tom^9000~anil
kumar^1000~asdad^9002~ganesh^9001~hari^6002~jack^7878~pete^9005~pravin
_
[/CODE]
 
Bill Johnston
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"The above coding worked properly. I have added one new employee and the above code is not working"

Not sure if it's working or not?
 
Micheal John
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I executed the below query in the toad and it returned 12 rows.

SELECT EMPLOYEEID,EMPLOYEENAME FROM EMPLOYEEINFO WHERE EMPLOYEEGRADE LIKE 'E%' AND ACTIVATIONSTATUS='Y' ORDER BY EMPLOYEENAME


By the coding, It's returning upto the record 9000-pravin and it is stored in the string EmployeeInfo, after that it just hanged and nothing is happening and the page is keep on loading.

Since I am having only limited records (12 records only), why it is not returning all the records..?
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you paste the code where you are invoking this method..
 
Micheal John
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I executed the below query in the toad and it returned 12 rows.

SELECT EMPLOYEEID,EMPLOYEENAME FROM EMPLOYEEINFO WHERE EMPLOYEEGRADE LIKE 'E%' AND ACTIVATIONSTATUS='Y' ORDER BY EMPLOYEENAME


By the coding, It's returning upto the record 9000-pravin and it is stored in the string EmployeeInfo, after that it just hanged and nothing is happening and the page is keep on loading.

Since I am having only limited records (12 records only), why it is not returning all the records..?
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi micheal,

Can you paste the code ...
where you invoke...this method ..

getEmployeeIdAndNameDeveloper(conn,stmt,rs,projectName);

Regards
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34672
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Note that this overwrites the EmployeeInfo variable. This means you will only get the last value returned in the string. (This doesn't necessarily have to be the last row in the table.)

Using the following will append the records into the EmployeeInfo variable.
EmployeeInfo += EmployeeInfo+ ROW_SEPARATOR + ...
 
Bill Johnston
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No Jeane that is not true.

EmployeeInfo = EmployeeInfo+ ...

is the same as EmployeeInfo += ...

~Bill
 
Bill Johnston
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't pass the Statement Object and the ResultSet Object in, only the Connection Object. I'd rather keep the former two local, build them in the method and then close them in the method ... I think that is your problem, you are not closing them. Don't forget to close them in the opposite order you build them.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34672
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bill Johnston:
No Jeane that is not true.

Doh! I knew that. For some reason, I read it as "EmployeeInfo = ROW_SEPARATOR ..." rather than what was actually written.
 
Micheal John
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Micheal John
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have posted the coding...any help....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic