解决方案 »

  1.   

    com.microsoft.sqlserver.jdbc.SQLServerException: 用户 'sa  ' 登录失败。  数据库登陆都没成功,用户名、密码检查下
      

  2.   

    --在需要的地方引用日志对象,不知道是不是这样写
    public class LoginValidate extends HttpServlet {
     private static Logger logger = Logger.getLogger(LoginValidate.class);  //日志文件(请看这句代码)
    /**
     * The doGet method of the servlet. <br>
     * 
     * This method is called when a form has its tag value method equals to get.
     * 
     * @param request
     *            the request send by the client to the server
     * @param response
     *            the response send by the server to the client
     * @throws ServletException
     *             if an error occurred
     * @throws IOException
     *             if an error occurred
     */
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException { doPost(request, response); } /**
     * The doPost method of the servlet. <br>
     * 
     * This method is called when a form has its tag value method equals to
     * post.
     * 
     * @param request
     *            the request send by the client to the server
     * @param response
     *            the response send by the server to the client
     * @throws ServletException
     *             if an error occurred
     * @throws IOException
     *             if an error occurred
     */
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    request.setCharacterEncoding("utf-8");
    response.setContentType("text/html;charset=utf-8");
    PrintWriter out = response.getWriter();
    HttpSession session = request.getSession();
    String rand = request.getParameter("rand");
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    String useryzm = (String) session.getAttribute("useryzm");
    if (useryzm != null && !useryzm.equals("")) {
    if (!useryzm.equals(rand.trim())) {
    out.print("1");
    out.flush();
    out.close();
    return;
    }
    } else {
    System.out.println("系统验证码获取失败!");
    return;
    }
    TransactionContext tran;
    try {
    tran = new TransactionContext();
    tran.beginTran(false);
    UserDAO dao = new UserDAO(tran);
    UserVO vo = dao.queryData(username, password);
    if (vo.getUsername() != null && !vo.getUsername().equals("")) {
    session.setAttribute("user", vo);
    logger.info(username+"用户登陆成功"+" "+"user_loginip:"+request.getRemoteAddr());(请看这句代码)
    out.print("2"); } else {
    logger.info("此用户不存在,登陆失败");
    out.println("用户名或者密码错误!"); }
    tran.commitTran();
    out.flush();
    out.close();
    } catch (TranSysException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } }}
      

  3.   

    log4j:ERROR Failed to excute sql --这句代码报错我的配置文件有问题,不知道怎么办