日期:2014-05-17  浏览次数:20763 次

哪位大大帮我看下啊,我新手T.T
一下是代码

// servlet login
package fy;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import fy.connbean;
import java.sql.*;

public class login extends HttpServlet
{ public void doPost(HttpServletRequest request,HttpServletResponse response)throws javax.servlet.ServletException, java.io.IOException
{ response.setContentType("text/html;charset=GB2312");
HttpSession session = request.getSession();
String User_Name,User_Password;
User_Name=request.getParameter("name");
User_Password=request.getParameter("password");
connbean logcon =new connbean();
logcon.setDbName("fyusers");
logcon.setTableName("userdata");
Connection con=logcon.getconn();
Statement stmt=new con.getStmt();
ResultSet rs=new Stmt.getRs();
String sql="select * from userdata where name='"+User_Name+"'";
rs=stmt.executeQuery(sql);
rs.last();
//out.println(sql);
if (rs.getRow()>0)
{ sql="select password from userdata where name='"+User_Name+"'";
rs=stmt.executeQuery(sql);
rs.last();
if(!rs.last().equals("password"))
response.sendRedirect("err.jsp?Warning='密码错误!'");
else 
session.putAttribute("1",flag);
out.println("<font size=2 color=blue>登陆成功!</font><meta http-equiv='refresh' content='2;url=index.jsp'>");


}
else{
response.sendRedirect("err.jsp?Warning='账号不存在!'");
}}
public void doGet(HttpServletRequest request,HttpServletResponse response)throws javax.servlet.ServletException, java.io.IOException{ doPost(request,response);
}下面是编译为CLASS时出现的错误:
求教啊~ 感激涕零..T.T 用到的connbean是编译成功的 就提供初始化一个数据库连接conn和创建stmt和指针的方法

------解决方案--------------------
LZ,你的图挂了!
------解决方案--------------------
if(!rs.last().equals("password"))

------解决方案--------------------
为什么好多人在方法里定义变量不同时初始化,很不好的习惯