java.sql.SQLException: Column not found
843840Sep 11 2007 — edited Sep 19 2007Hey guys,
I am getting the error:
javax.servlet.ServletException: Column not found and
java.sql.SQLException: Column not found for EMP_ID AND PASSWORD.
But both these columns are present in the table.
It is working normally if oly the java code is extracted from the JSP code written below.
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page language ="java" import = "java.io.*, java.lang.*, java.sql.*,java.net.*,javax.sql.*" %>
<html>
<body bgcolor="green">
<%
String strUsername = request.getParameter("uname");
String strPassword = request.getParameter("pass");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection myConn=DriverManager.getConnection("jdbc:odbc:aatish","aatish","aatish");
String str="SELECT * FROM EMPLOYEE";
Statement statement=myConn.createStatement();
String ip=request.getRemoteAddr();
ResultSet rs=statement.executeQuery(str);
int i=0;
while(rs.next())
{
String id=rs.getString("EMP_ID");
String pwd=rs.getString("PASSWORD");
if(id.compareTo(strUsername)==0&&pwd.compareTo(strPassword)==0)
{
Connection myConn1=DriverManager.getConnection("jdbc:odbc:aatish","aatish","aatish");
String str1="INSERT INTO SESSION VALUES(?,?)";
PreparedStatement ps = myConn1.prepareStatement(str1);
ps.setString(1,strUsername);
ps.setString(2,ip);
int rt=ps.executeUpdate();
ps.close();
myConn1.close();
response.sendRedirect("index.htm");
i=1;
break;
}
}
rs.close();
statement.close();
myConn.close();
if(i==0)
response.sendRedirect("loginfail.html");
%>
</body>
</html>
Please help me out. I have been stuck on this issue for the past couple of days.
Waiting for your reply.