<html>
<body>
<%@ page import="java.sql.*,java.io.*" %>
<%
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con
=
DriverManager.getConnection
("jdbc:oracle:thin:@suresh:1521:orcl","scott","tiger");
String username=request.getParameter("username");
String psw=request.getParameter("psw");
if(session.isNew())
{
session.setAttribute("username",username);
session.setAttribute("psw",psw);
}
PreparedStatement ps = con.prepareStatement("select psw from users");
ResultSet rs = ps.executeQuery();
//ps.setString(1,username);
rs.next();
ResultSetMetaData rsmd = rs.getMetaData();
int count = rsmd.getColumnCount();
String ret=new String();
ret=rs.getString(1);
if(psw.equals(ret))
{
%>
<h1>Welcome <%= username %>... </h1>
<%
}
else
{
response.sendRedirect("error.html");
}
%>
</body>
</html>
Solutions : put rs.next() before getting metadata