发布时间:2019-07-29 16:53:43
Class.forName(".microsoft.sqlserver.jdbc.SQLServerDriver");Connection conn = DriverManager.getConnection( "jdbc:sqlserver://localhost:1433;databaseName=bysjglxt","sa","123456");String username=request.getParameter("username"); String password=request.getParameter("mima"); String lx= new String(request.getParameter("lx").getBytes("8859_1")); //PreparedStatement stmt = conn.prepareStatement(sql); if(lx.equals("学生")) { sql="select * from xueshengxinxi where xuehao='"+username+"' and mima='"+password+"'"; } else { sql="select * from jiaoshixinxi where gonghao='"+username+"' and mima='"+password+"'"; }PreparedStatement stmt = conn.prepareStatement(sql); ResultSet RS_result=stmt.executeQuery(); if(RS_result.next()){ out.println("<script>alert('你输入的用户不存在或密码错误,请重新登录!');window.history.go(-1);</script>"); }else{ session.setAttribute("username",username); session.setAttribute("lx",lx); response.sendRedirect("index.jsp"); }
这个肯定是没有结果的