在dreamweaver中用jsp做登录网页连接数据库后同时显示:
代码如下:<%Stringusr=request.getParameter("username");Stringpwd=request.getParameter("pas...
代码如下:
<%
String usr=request.getParameter("username");
String pwd=request.getParameter("password");
try{
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost/mysql","root","369248");
String sql="select * from student where username=? and password=?";
PreparedStatement ps=conn.prepareStatement(sql);
ps.setString(1,usr);
ps.setString(2,pwd);
ResultSet rs=ps.executeQuery();
if(rs.next()){
response.sendRedirect("ok.jsp");
}
else
out.println("<script language='javascript'>");
out.println("alert('用户名或密码错误')");
out.println("</script>");
rs.close();
conn.close();
}
catch(Exception e){
out.println("系统忙,请稍后再试。。。"+e);
}
%>
这是什么情况? 展开
<%
String usr=request.getParameter("username");
String pwd=request.getParameter("password");
try{
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost/mysql","root","369248");
String sql="select * from student where username=? and password=?";
PreparedStatement ps=conn.prepareStatement(sql);
ps.setString(1,usr);
ps.setString(2,pwd);
ResultSet rs=ps.executeQuery();
if(rs.next()){
response.sendRedirect("ok.jsp");
}
else
out.println("<script language='javascript'>");
out.println("alert('用户名或密码错误')");
out.println("</script>");
rs.close();
conn.close();
}
catch(Exception e){
out.println("系统忙,请稍后再试。。。"+e);
}
%>
这是什么情况? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询