JSP网上购物系统//用户登入数据库连接
来源:互联网 发布:我们来了网络播出时间 编辑:程序博客网 时间:2024/06/10 22:47
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.util.*,java.sql.*" errorPage="" %>
<%
Connection con=null;
try{
Class.forName("com.mysql.jdbc.Driver"); //载入驱动程序
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test_table?useUnicode=true&characterEncoding=gb2312","root","123456"); //连接数据库
}catch(ClassNotFoundException e){
out.print(e);
}
//数据库连接对象con如果不为空的话则表示已成功连接上数据库网上销售系统数据
//
String id=request.getParameter("id");//获取用户名
String pwd=request.getParameter("password"); //获取密码
System.out.print(id+""+pwd);
String query = "SELECT * FROM admin WHERE id=? and password=?" ;
PreparedStatement pstmt = null ; //创建PreparedStatement对象
pstmt = con.prepareStatement(query) ; //发送sql语句
pstmt.setString(1,id) ;
pstmt.setString(2,pwd) ;
ResultSet resultset= pstmt.executeQuery( ) ; //得到结果集
try{
if(resultset.next()){
session.setAttribute("userId", id);//登录成功将用户名 存入session
response.sendRedirect("loginSuccess.jsp");//网页跳转回页面
}else{
request.setAttribute("errInf"," *密码与账号不匹配");
}
}catch(SQLException sqle){
System.err.println("Erro with connection:"+sqle);
}
con.close();
pstmt.close();
%>
阅读全文
0 0
- JSP网上购物系统//用户登入数据库连接
- Flex和Jsp创建用户登入系统
- 网上购物系统.......jsp+++++javabean (一)
- 机房登入系统
- 01---实例操作(用户登入系统)
- 用JAVA做一个用户登入系统
- 判定用户是否登入
- ubuntu登入root用户
- Flask用户登入登出
- PHP登入登出系统
- 【用户管理】查看用户登入信息
- 【用户管理】查看用户登入信息
- 网上购物系统
- 网上购物系统
- 网上购物系统
- linux系统新建一个登入用户,并且禁用root用户
- (jsp和Servlet功能篇) session判断用户是否登入
- JSP中cookie的使用方法(用户登入_客户端读取及发送)
- 算法导论B树的c++实现
- 25年的思考沉淀,只为成就这一款经典
- PHP 策略者模式 清晰总结
- Shiro Odd number of characters.
- SQLServer根据表名创建三层架构的Model
- JSP网上购物系统//用户登入数据库连接
- ubuntu下php5.6安装
- 代码设置RelativeLayout相对位置设置
- QT 乱码问题
- 关于MySQL版本与HIbernate版本不匹配的问题,注意事项!!
- Lua中如何防止sql注入
- 矩阵分解 Cholesky分解
- acticle
- SprigBoot核心注解详解及核心配置大全(持续更新)