JSP用户名和密码登陆,提示帐户不存在?
密码验证
<%@include file="dbsconn.jsp"%><% Statement st; st=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); String login_name = request.getParameter("login_name"); String password=request.getParameter("password"); String sql="select count(*) from UserT where UserName like " + login_name + " and password like '" + password + "'"; ResultSet rs=st.executeQuery(sql); if(rs.getInt(0)!=0) response.sendRedirect("/main.jsp"); else response.sendRedirect("login.jsp"); session.setAttribute("grade",""); session.setAttribute("BranchID",""); session.setAttribute("NodeID",""); session.setAttribute("UserPrivate",""); session.setAttribute("UserId",""); %>
Connection conn = null; String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; //String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; String url = "jdbc:microsoft:sqlserver://localhost:1433;databaseName=NetBank"; String name = "sa"; String pass = "123456";//连接数据库的方法try{System.out.println("***加载数据库驱动***");Class.forName(driver);System.out.println("***数据库驱动加载成功***");System.out.println("***连接数据库***");conn = DriverManager.getConnection(url, name, pass);System.out.println("***数据库连接成功***");} catch (ClassNotFoundException ce){System.out.println("找不到jar驱动包或者驱动连接字符出错!");ce.printStackTrace();} catch (SQLException se){System.out.println("SQL连接字符串出错!");se.printStackTrace();} catch (Exception e){e.printStackTrace();}%>