java吧 关注:1,227,586贴子:12,686,062
  • 0回复贴,共1

求助JAVA连接问题

只看楼主收藏回复

<%
Statement statement;
ResultSet rs;
%>
<% //加载驱动
try {
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/hacker", "root", "111111");
System.out.println("连接成功");
statement=connection.createStatement();
rs=statement.executeQuery("select password from user where username="+"*"+request.getParameter("username")+"*");
if(rs.next())
{
String bb = rs.getString("password");
String aa = rs.getString("name");
System.out.println("tongguo");
if(request.getParameter("userpassword").equals(bb)&&request.getParameter("username").equals(aa))
response.sendRedirect("http://localhost:8080/cat");
}
else {
out.println("失败"); // 用户名和密码错误,跳转到登录界面
}
自己感觉是IF那里出错了,因为根本就没有走IF,直接就走else了,求帮忙怎么改,如果能说怎么错就更好了。JSP页面


IP属地:广东1楼2014-08-11 17:09回复