Hi;
The below jsp page is compiling fine but executing it shows error asjavax.servlet.ServletException: java.sql.SQLException: Column 'Total' not found.
<%--
Document : evaluationeventtable
Created on : Jul 24, 2008, 6:52:37 PM
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>Table-Data</title>
</head>
<body>
<% int QNO;
String ID=request.getParameter("id");
out.println(ID);
String EVENTID=request.getParameter("event");
out.println(EVENTID);
Connection connection = null;
Statement st = null;
Statement st1 = null;
Statement st2 = null;
Statement st3 = null;
Statement st4 = null;
Statement st5 = null;
ResultSet rs= null;
ResultSet rs1= null;
ResultSet rs2= null;
ResultSet rs3= null;
ResultSet rs4= null;
ResultSet rs5= null;
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mynewdatabase","root", "root123");
st5=con.createStatement();
int count=0;
try {
rs5=st5.executeQuery("select count(*) from Final where Eventid='"+EVENTID+"'");
while(rs5.next())
{count=rs5.getInt(1);
out.println(count);
}
} finally
{
if (rs5 != null)
{
rs5.close();
rs5 = null;
}
if (st5 != null)
{
st5.close();
st5 = null;
}
}
st=con.createStatement();
try {
for( QNO=1;QNO<=count;QNO++);
rs = st.executeQuery("SELECT * FROM Questionbank where Questionid='"+ID+"'");
while ( rs.next() )
{
%>
<tr>
<input type="hidden" name="Qserino" value="<%=rs.getString("qserialno")%>"/>
<td colspan="5"><b>Question:</b>
<%=rs.getString("questionname")%>
</td>
</tr>
<%
st1=con.createStatement();
try {
rs1=st1.executeQuery("select count(*) as Total from final where questionid='"+ID+"'and Eventid='"+EVENTID+"'and Qserialno='"+QNO+"'and Answer='A'");
while(rs1.next())
{
%>
<tr>
<td colspan="5"><b>No. of A:</b>
[B]<%=rs.getString("Total")%>[/B]
</td>
</tr>
<%
}
} finally
{
if (rs1!= null)
{
rs1.close();
rs1= null;
}
if (st1 != null)
{
st1.close();
st1 = null;
}
}
%>
<%
st2=con.createStatement();
try {
rs2=st2.executeQuery("select count(*) as Total1 from final where questionid='"+ID+"' and Eventid='"+EVENTID+"'and Qserialno='"+QNO+"'and Answer='B'");
while(rs2.next())
{
%>
<tr>
<td colspan="5"><b>No. of B:</b>
<%=rs.getString("Total1")%>
</td>
</tr>
<%
}
} finally
{
if (rs2!= null)
{
rs2.close();
rs2= null;
}
if (st1 != null)
{
st1.close();
st1 = null;
}
}
%>
<%
st3=con.createStatement();
try {
rs3=st3.executeQuery("select count(*) as Total2 from final where questionid='"+ID+"' and Eventid='"+EVENTID+"'and Qserialno='"+QNO+"'and Answer='C'");
while(rs3.next())
{
%>
<tr>
<td colspan="5"><b>No. of C:</b>
<%=rs.getString("Total2")%>
</td>
</tr>
<%
}
} finally
{
if (rs3!= null)
{
rs3.close();
rs3= null;
}
if (st3 != null)
{
st3.close();
st3 = null;
}
}
%>
<%
st4=con.createStatement();
try {
rs4=st4.executeQuery("select count(*) as Total3 from final where questionid='"+ID+"' and Eventid='"+EVENTID+"'and Qserialno='"+QNO+"'and Answer='D'");
while(rs4.next())
{
%>
<tr>
<td colspan="5"><b>No. of D:</b>
<%=rs.getString("Total3")%>
</td>
</tr>
<%
}
} finally
{
if (rs4!= null)
{
rs4.close();
rs4= null;
}
if (st4 != null)
{
st4.close();
st4 = null;
}
}
%>
<%
}
} finally
{
if (rs != null)
{
rs.close();
rs = null;
}
if (st != null)
{
st.close();
st = null;
}
}
%>
</body></html>
Thansk in advance
Regards
Haresh