zoukankan      html  css  js  c++  java
  • 发际线与我作队团队作业(五):冲刺总结4

    冲刺总结4--数据库

    我组采用的数据库是Mysql

    • MySQL所使用的 SQL 语言是用于访问数据库的最常用标准化语言。MySQL 软件采用了双授权政策,分为社区版和商业版,由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,一般中小型网站的开发都选择 MySQL 作为网站数据库。
    • 工具准备
      • 安装Mysql

      • 安装XAMPP

    数据库设置

    文件类

    /*Table structure for table `t_file` */
    
    DROP TABLE IF EXISTS `t_file`;
    
    CREATE TABLE `t_file` (
      `id` int(4) NOT NULL auto_increment,
      `title` varchar(50) default NULL,
      `remark` varchar(1000) default NULL,
      `url` varchar(200) default NULL,
      `inputdate` varchar(50) default NULL,
      `fromuser` int(4) default NULL,
      `touser` int(4) default NULL,
      `status` int(4) default NULL,
      `typeid` int(4) default NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    
    /*Data for the table `t_file` */
    
    insert  into `t_file`(`id`,`title`,`remark`,`url`,`inputdate`,`fromuser`,`touser`,`status`,`typeid`) values (1,'档案管理','档案管理','2013-03-29-14-46-42F.chm','2013-03-29 14:46:45',3,4,2,1);
    

    • 共设置了九个文件属性,包括编号、标题、备注、文件名、上传时间、发送者、接受者、文件状态和文件类别
    • 文件类别包括加密和普通
    /*Table structure for table `t_filetype` */
    
    DROP TABLE IF EXISTS `t_filetype`;
    
    CREATE TABLE `t_filetype` (
      `id` int(4) NOT NULL auto_increment,
      `typename` varchar(50) default NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    
    /*Data for the table `t_filetype` */
    
    insert  into `t_filetype`(`id`,`typename`) values (1,'加密'),(2,'普通');
    

    用户类

    /*Table structure for table `t_user` */
    
    DROP TABLE IF EXISTS `t_user`;
    
    CREATE TABLE `t_user` (
      `id` int(4) NOT NULL auto_increment,
      `username` varchar(50) default NULL,
      `password` varchar(50) default NULL,
      `realname` varchar(50) default NULL,
      `role` varchar(50) default NULL,
      `departmentid` int(4) default NULL,
      `zhiwei` varchar(50) default NULL,
      `tel` varchar(50) default NULL,
      `email` varchar(50) default NULL,
      `zuzhiid` int(4) default NULL,
      `sex` varchar(50) default NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    
    /*Data for the table `t_user` */
    
    insert  into `t_user`(`id`,`username`,`password`,`realname`,`role`,`departmentid`,`zhiwei`,`tel`,`email`,`zuzhiid`,`sex`) values (1,'admin','1','管理员','0',NULL,'','13800000000','admin@163.com',NULL,'男'),(2,'xiaoming','1','王明','1',1,'','13800000000','xiaoming@163.com',1,'男'),(3,'xiaohong','1','小红','2',1,'初级职员','13800000000','xiaohong@163.com',1,'女'),(4,'xiaowang','1','小王','2',1,'','13800000000','xiaowang@163.com',1,'男'),(5,'xiaoli','1','小李','1',2,'初级职员','13800000000','xiaoli@163.com1',2,'男');
    


    - 共设置了11个用户属性,包括序号、用户名、密码、真实姓名、角色、单位、职位、电话、邮箱、组织、性别

    单位类

    - 设置了两个单位
    
    /*Table structure for table `t_department` */
    
    DROP TABLE IF EXISTS `t_department`;
    
    CREATE TABLE `t_department` (
      `id` int(4) NOT NULL auto_increment,
      `departmentname` varchar(50) default NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    
    /*Data for the table `t_department` */
    
    insert  into `t_department`(`id`,`departmentname`) values (1,'单位1'),(2,'单位2');
    

    登录验证

    //获取登录页面的账号、密码
    	String username = request.getParameter("username");
    	String password = request.getParameter("password");
    	String role = request.getParameter("role");
    	ResultSet rs = null;
    	try{
    		String sql = "select * from t_user where  username='"+username.trim()+"'";
    		rs = stmt.executeQuery(sql);
    	if (rs.next()) {
    			if (rs.getString("password").equals(password)&&rs.getString("role").equals(role)) {//账号验证成功
    				session.setAttribute("username", username);
    				session.setAttribute("realname",rs.getString("realname"));
    				session.setAttribute("role",rs.getString("role"));
    				session.setAttribute("id", rs.getString("id"));
    				session.setAttribute("departmentid",rs.getString("departmentid"));
    				response.sendRedirect("../../index.jsp");	
    			}else{//账号验证失败跳转登录界面
    				response.sendRedirect("../../login.jsp?info=0");
    			}
    		}else{//账号验证失败跳转登录界面
    			response.sendRedirect("../../login.jsp?info=1");
    		}
    	} catch (Exception e) {
    		out.println(e.getMessage());
    	} finally {
    		if (rs != null) {
    			try {
    				rs.close();
    			} catch (Exception e) {
    				e.printStackTrace();
    			}
    		}
    		if (stmt != null) {
    			try {
    				stmt.close();
    			} catch (Exception e) {
    				e.printStackTrace();
    			}
    		}
    		if (conn != null) {
    			try {
    		conn.close();
    			} catch (Exception e) {
    		e.printStackTrace();
    			}
    		}
    	}
    

    任务燃尽图

    小组会议

    参考资料

    通过JSP网页连接Mysql数据库
    jsp连接mysql实现登录

  • 相关阅读:
    Java网络编程
    IDEA maven-3.6.2 Unable to import maven project错误
    Java通过ArrayList的contains(Object o)方法实现去重字符串中的字符
    常用的Unicode值范围
    Java函数(方法)的默认值问题
    [Noip2017]宝藏
    [Noip2017]组合数问题
    [Noip2018]赛道修建
    [Noip2018]旅行(数据加强版)
    [Noip2019]树的重心
  • 原文地址:https://www.cnblogs.com/dongjiashuai/p/15646163.html
Copyright © 2011-2022 走看看