| Author |
How to retrive data two times from database in sinble jsp page.
|
Harshal Gurav
Ranch Hand
Joined: May 29, 2008
Posts: 150
|
|
Hi, I am trying to retrieve data from table in two times. In first query I am displaying all data available in table. Now I want to count the no. Of rows available in the same table by using select count(*)from table-name type query. How can I retrieve records of same table by firing these two queries in single jsp page : Please Tell me how to execute to query un single jsp page. Here is an page where i able to fired the single query to display the table : Thanks in advance ................. Harshal
|
 |
Saicharan velury
Greenhorn
Joined: Jul 22, 2008
Posts: 3
|
|
hi harshal from your query and code displayed i understand that you are trying to display the details of a particular question from the question table. you have done one part that is displaying the details from a table which is your first doubt solution to your second doubt is quite simple create another Statement st1 and another ResultSet rs1 now in the same jsp after you have closed the existing st and rs <code> st1.executeQuery("select count(*) from question"); int count=0; while(rs1.next()) { count=rs1.getInt(1); } out.println(count); </code> i am sure this will give you the count of the questions in the same jsp page.
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
|
Why don't you just count the rows as you process them? Then you would not need to do that second query.
|
 |
Harshal Gurav
Ranch Hand
Joined: May 29, 2008
Posts: 150
|
|
Hi saicharan, Thank you very much for your post. you suggested code is worked fine with given output as no of question in that particular question bank. Regards Harshal
|
 |
Harshal Gurav
Ranch Hand
Joined: May 29, 2008
Posts: 150
|
|
Hi, I am Trying to pass an integer value that is an no. of row of table to next jsp page. for that i am trying to convert int value to string format but showing error in marked lines: Kindly suggest me an updated code. Thanks and Regards Harshal
|
 |
Rajkumar balakrishnan
Ranch Hand
Joined: May 29, 2008
Posts: 445
|
|
Is it the actual code that you use.. If so then it's simple... Your code is like this Just open and close the scriplet tags in proper place like the below one... Just look at the code that is in BOLD... It use proper scriplets... Hope you will be clear in future.. [ July 23, 2008: Message edited by: Rajkumar balakrishnan ]
|
Never try to be a hard-worker. Be a smart-worker.
My Blog
|
 |
 |
|
|
subject: How to retrive data two times from database in sinble jsp page.
|
|
|