<%@ page contentType="text/html;charset=GB2312"%>
<%@ page import="java.util.*,java.sql.*"%>
<%
String s_theuser=request.getParameter("theuser");
String s_passwd=request.getParameter("thepasswd");
String driverClass="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String url="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=db_user";
String username="sa";
String password="";
Class.forName(driverClass);
Connection conn=DriverManager.getConnection(url,username,password);
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from user_info where user_name='"+s_theuser+"' and passwd='"+s_passwd+"'");
if(rs.next()){
session.setAttribute("theuser",s_theuser);
response.sendRedirect("index.jsp");
}
else
{
response.sendRedirect("login.jsp");
}
%>
这是我写的一段代码,但是每次都是直接执行else那步,也就是跳到login.jsp
并没有成功过跳到index.jsp
我的数据库没有写错,我另外写了一个代码,能执行出数据库的内容,所以我想数据库是不会有错了,谁能帮我看下是哪错.
我无论输入正确还是错误,总是会跳到else那步.