servlet编译时出错,老是提示软件包lft.bean不存在
我写的是一个登陆验证的servlet,里面调用了classes\lft\bean下的DatabaseConn类(用于连接数据库)
servlet代码如下:
package lft.servlet;import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import lft.bean.*;
public class CheckServlet
    extends HttpServlet
{
    private static final String CONTENT_TYPE = "text/html; charset=GBK";
    
    public void init()
        throws ServletException
    {
    }   public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws
        ServletException, IOException
    {
        String a = request.getParameter("username");
        String b = request.getParameter("userpwd");
        Connection conn = DatabaseConn.getConnection( );
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery("select username,password from user" );
        String uname = rs.getString("username"); 
        String psw = rs.getString("password"); 
         if (uname.equals(a) && psw.equals(b))
           {
            response.sendRedirect("welcome.jsp");
           }
         else
           {
            response.sendRedirect("index.html");
           }
    }   public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws
        ServletException, IOException
    {
        doGet(request, response);
    }    //Clean up resources
    public void destroy()
    {
    }
}
问题出在哪里,请高人指点!!

解决方案 »

  1.   

    ResultSet rs = stmt.executeQuery("select username,password from user" );
    try{ //加入
    while(rs.next()){//加入,重点是这一句
    String uname = rs.getString("username");
    String psw = rs.getString("password"); 
    }//加入
    }catch(SQLException e){//加入

    }//加入
      

  2.   

    DatabaseConn下getConnection( );如何定义的?
    public static getConnection(){
    ...
    }
    是这样吗?
      

  3.   

    这是DatabaseConn
    package lft.bean;import java.sql.*;
    import javax.naming.*;
    import javax.sql.DataSource;//一个用于查找数据源的工具类。
    public class DatabaseConn {
    public  static  synchronized Connection getConnection() throws Exception
    {
    try
    {

            Context initCtx = new javax.naming.InitialContext(); 
                    Context envCtx = (Context) initCtx.lookup("java:comp/env"); 
                    DataSource ds = (DataSource)envCtx.lookup("jdbc/lftsql"); ;
    return ds.getConnection();
    }
    catch(SQLException e)
    {
    throw e;
    }
    catch(NamingException e)
    {
          throw e;
    }

    }}
      

  4.   

    不好意思,定义应为:
    DatabaseConn下getConnection( );如何定义的?
    public static Connection  getConnection(){
    ...
    }
      

  5.   

    上面有DatabaseConn的源码,你帮我看看