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:

<%-- 
    Document   : fillquestion
    Created on : Jul 18, 2008, 10:07:43 AM
    Author     : user1
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language ="java" %>
<%@ page import="java.sql.*, javax.sql.*, javax.naming.*,java.io.*,java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Fill-up-Question</title>
    </head>
    <body>
    <form name="fill-ok" action="fill-question-ok.jsp" method="POST">
        
        <table width="50%" border="1" borderColor="#000066" cellspacing="0" cellpadding="5" align="center">
              <TBODY>
	<tr>
		<td colspan="8" align="middle" class="StripColor">
			<font class="FontGeneralBoldWhite">Fill Up the Question</font>
                        
		</td>
	</tr> 
        
        <%
        String ID=request.getParameter("id"); 
        String EVENTID=request.getParameter("even");
        Connection connection = null;
        Statement st = null;
        ResultSet rs = null;
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mynewdatabase","root", "root123");
         st=con.createStatement();
           try {
            rs = st.executeQuery("SELECT * FROM questionbank where questionid='"+ID+"'LIMIT 5");
        
         while ( rs.next() )
	   {
            %>
            
                      

	    <tr>
             <input type="hidden" name="Event" value="<%=request.getParameter("event")%>"/>
             <input type="hidden" name="ID" value="<%=request.getParameter("id")%>"/>
             <input type="hidden" name="QseriNO" value="<%=rs.getString("qserialno")%>"/>
		
               <td><%=rs.getString("qserialno")%>:&nbsp;&nbsp;<b>Question:</b>
               <%=rs.getString("questionname")%>
		</td>
                </tr>
                <tr>
                 //<td><input type="hidden" name="QserialNO" value="<%=request.getParameter("Qserialno")%>"></td>
                <td><b>A:</b><input type="radio" name="answer<%=rs.getString("qserialno")%>" value="A" /><%=rs.getString("OptionA")%></td>           
                <td><B>B:</B><input type="radio" name="answer<%=rs.getString("qserialno")%>" value="B" /><%=rs.getString("OptionB")%></td>
                <td><B>C:</B><input type="radio" name="answer<%=rs.getString("qserialno")%>" value="C" /><%=rs.getString("OptionC")%></td> 
                <td><B>D:</B><input type="radio" name="answer<%=rs.getString("qserialno")%>" value="D" /><%=rs.getString("OptionD")%></td>                 	
                </tr>             
		        <%
                           }

                       }   finally
                       {
                           if (rs != null)
                           {
                               rs.close();
                               rs = null;
                           }
                           if (st != null)
                           {
                               st.close();
                               st = null;
                           }

                       }
                      
                   %>
    </table>
    <tr>
                <TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="SUBMIT" name="submit" /></TD>
                <td><input type="reset" value="RESET" name="reset" /></td>
                    
	       </tr>
   </form>
   </body>
   </html>

Thanks in advance
..............................
Haresh

Modify query like this.

SELECT *,count(questionid) as count FROM questionbank where questionid='"+ID group by questionid

If you want that count to be executed as different query, use different result set.

The count will give the answer

For more code snippets

<URL SNIPPED>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.