加载驱动 新建连接 建立状态 操作 update close
<%
Connection conn=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
boolean flag=false;
%>
<%
String UID=request.getParameter("UID");
String psw=request.getParameter("psw");
try{
Class.forName(DBDRIVER);
conn=DriverManager.getConnection(DBURL,DBUSER,DBPSW);
String sql="SELECT UID,psw FROM student WHERE UID=? AND psw=?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,UID);
pstmt.setString(2,psw);
rs=pstmt.executeQuery();
if(rs.next()){
flag=true;
}
}catch(Exception e){ out.println(e.toString());
}finally{
try{
conn.close();
}catch(Exception e){ out.println(e.toString());
}
}
本文如未解决您的问题请添加抖音号:51dongshi(抖音搜索懂视),直接咨询即可。