有一个登陆页面,负责接收登陆页面中表单传来的值,并去数据库(MySQL 8.0)nuc数据库中的表user中验证用户名和密码,若存在此用户,则跳转至用户成功登录后的页面,否则输出错误信息。请根据上面的描述,在下划线上填充。合适的代码将的程序段补充完整。
<%@ page contentType="text/html" pageEncoding="utf-8" %>
<%@ page import=".*" %>
<html>
<body>
<% String username=request.getParameter("username");
String password=request.getParameter("password"); %>
<% Connection conn=null;
PreparedStatement ps=null,
ResultSet rs=null.
String sql, %>
<% try{
// 加载驱动
_______________⑨_______________;
String url ="jdbc:mysql://localhost:3306/nuc?useSSL=false&serverTimezone=C
ST&characterEncoding=utf-8";
// 通过驱动类的方法获得数据库连接
conn = DriverManager._______(url,"root","root");
// 装载拼接SQL语句
sql = "____11____where username="+username+"and password="+password;
ps=conn.prepareStatement(sql);
rs=pre.executeQuery();
// 判断结果集是否为空
if( ____12____ ){
%>
<jsp:forword page="/" />
<%
}else{
out.print("<h1>登录的用户名密码不正确</h1>");
}
}catch(Exception e){
}
%>
</body>
</html>