login check urgent
I am facing some problems while checking the login for a particular user in my project...I m pasting my code..can someone please correct it if they can spot the error..
************************************************** *******************
<html>
<head>
<title>JDBC Connection </title>
</head>
<body>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%
Connection conn = null;
ResultSet rs=null;
String name=new String();
String passwd=new String();
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@10. 100.56.16:1521:btech9", "200412042", "ans");
Statement stmt = conn.createStatement();
rs = stmt.executeQuery("select username,password from ch where username='"+request.getParameter("nm") + "' AND password=PASSWORD('"+request.getParameter("pwd")+" ')");
while(rs.next())
{
name=rs.getParameter(nm);
passwd=rs.getString(pwd);
}
if(nm.equals(name))
{
if(pwd.equals(passwd))
{
out.println("Login successful");
}
}
else
out.println("login denied");
}
catch(SQLException e)
{
System.out.println("SQLException: " + e.getMessage());
}
catch(ClassNotFoundException e)
{
System.out.println("ClassNotFoundException: " + e.getMessage());
}
finally
{
if(conn != null)
{
try
{
conn.close();
}
catch (Exception ignored) {}
}
}
%>
</body>
</html>
************************************************** *******************
ERROR:------->>>
D:\Apache Tomcat 4.0\work\localhost\_\ans\ex$jsp.java:85: Undefined variable: nm
name=rs.getParameter(nm);
^
ans4u
|