码迷,mamicode.com
首页 > 其他好文 > 详细

登录主程序

时间:2017-10-20 21:45:26      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:htm   html 4.01   dir   imp   char   pwd   redirect   主程序   pst   

<%@ page language="java" import="java.sql.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<body>
<%
Connection conn=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
String driverName="com.mysql.jdbc.Driver";
String userName="root";
String userPwd="19961009smx8s";
String dbName="jrs";
String url1="jdbc:mysql://localhost:3306/"+dbName;
String url2="?user="+userName+"&password="+userPwd;
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
request.setCharacterEncoding("UTF-8");
try{
Class.forName(driverName);
conn=DriverManager.getConnection(url);
String Name=request.getParameter("RdName");
String Passwd=request.getParameter("RdPasswd");
String sql="select * from users where username=? and password=?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,Name);
pstmt.setString(2,Passwd);
rs=pstmt.executeQuery();
if(rs.next()){
response.sendRedirect("ch03_11_loginCorrect.jsp");
}
else{
response.sendRedirect("fail.jsp"); } }
catch(Exception e){ }
finally {
if(rs!=null) {rs.close();}
if(pstmt!=null) {pstmt.close();}
if(conn!=null) {conn.close();}
}

%>
</body>
</html>

登录主程序

标签:htm   html 4.01   dir   imp   char   pwd   redirect   主程序   pst   

原文地址:http://www.cnblogs.com/jrsflak/p/7701289.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!