zoukankan      html  css  js  c++  java
  • 学生基本信息管理

    一.团队介绍

    201921123067徐亦菲(组长)
    主要工作:创建数据库,实现修改,删除,查找的功能
    201921123068郝冰冰
    主要工作:GUI界面设计,实现添加查看的功能

    二.项目Git地址

    https://gitee.com/hao-bingbing/java-code

    三.Git提交记录截图

    四.项目功能架构图

    五.项目运行截图








    六.关键代码

    添加学生信息

    public boolean addStu(Student student) {
    		Connection connection = DbUtil.getConnection();// 获得数据库连接对象
    		String sql = "INSERT INTO student(number,name,sex,birthday,politicalStatus,homeAddress,phone,dormitoryNum)values(?,?,?,?,?,?,?,?)";
    		try {
    			PreparedStatement ps = connection.prepareStatement(sql);
    			ps.setString(1, student.getNumber());
    			ps.setString(2, student.getName());
    			ps.setString(3, student.getSex());
    			ps.setString(4, student.getBirthday());
    			ps.setString(5, student.getPoliticalStatus());
    			ps.setString(6, student.getHomeAddress());
    			ps.setString(7, student.getPhone());
    			ps.setString(8, student.getDormitoryNum());
    			if (!ps.execute()) {
    				DbUtil.close(connection, ps);// 关闭连接
    				return true;
    			}
    		} catch (SQLException e) {
    			e.printStackTrace();
    		}
    		return false;// 失败
    	}
    

    删除学生信息

    public boolean delStu(String number) {
    		Connection connection = DbUtil.getConnection();
    		String sql = "delete from student where number=?";
    
    		try {
    			PreparedStatement ps = connection.prepareStatement(sql);
    			ps.setString(1, number);
    			if (!ps.execute()) {// 删除成功
    				DbUtil.close(connection, ps);// 关闭连接
    				return true;
    			}
    		} catch (SQLException e) {
    			e.printStackTrace();
    		}
    		return false;
    	}
    
    

    查找学生信息

    public Student findStu(String number) {
    		Connection connection = DbUtil.getConnection();
    		String sql = "SELECT number,name,sex,birthday,politicalStatus,homeAddress,phone,dormitoryNum FROM student where number=?";
    		try {
    			PreparedStatement ps = connection.prepareStatement(sql);
    			ps.setString(1, number);
    			ResultSet rs = ps.executeQuery();
    			if (rs.next()) {// 存在学生,封装返回
    				Student student = new Student(rs.getString("number"), rs.getString("name"), rs.getString("sex"),
    						rs.getString("birthday"),rs.getString("politicalStatus"),rs.getString("homeAddress"),rs.getString("phone"),rs.getString("dormitoryNum"));
    				DbUtil.close(connection, ps);// 关闭连接
    				return student;
    			}
    		} catch (SQLException e) {
    			e.printStackTrace();
    		}
    		return null;// 没有学生
    	}
    

    修改学生信息

    public boolean updateStu(Student student) {
    		Connection connection = DbUtil.getConnection();// 获得数据库连接对象
    		String sql = "update student set name=?,sex=?,birthday=?,politicalStatus=?,homeAddress=?,phone=?,dormitoryNum=? where number=?";
    		try {
    			PreparedStatement ps = connection.prepareStatement(sql);
    			ps.setString(1, student.getName());
    			ps.setString(2, student.getSex());
    			ps.setString(3, student.getBirthday());
    			ps.setString(4, student.getPoliticalStatus());
    			ps.setString(5, student.getHomeAddress());
    			ps.setString(6, student.getPhone());
    			ps.setString(7, student.getDormitoryNum());
    			ps.setString(8, student.getNumber());
    			if (!ps.execute()) {
    				DbUtil.close(connection, ps);// 关闭连接
    				return true;
    			}
    		} catch (SQLException e) {
    			e.printStackTrace();
    		}
    		return false;// 失败
    	}
    
    

    七.尚待改进的地方

    界面不够美观,实现功能较少且只能根据学号进行删除修改等操作,过于局限

  • 相关阅读:
    Luogu P3390 【模板】矩阵快速幂&&P1939 【模板】矩阵加速(数列)
    矩阵乘法&&矩阵快速幂&&最基本的矩阵模型——斐波那契数列
    EZ 2018 05 13 NOIP2018 模拟赛(十三)
    Luogu P2341 [HAOI2006]受欢迎的牛
    Deep learning_CNN_Review:A Survey of the Recent Architectures of Deep Convolutional Neural Networks——2019
    常用刷题网址——提高代码能力
    Computer Vision_33_SIFT:Fast Adaptive Bilateral Filtering——2018
    Computer Vision_33_SIFT:An Improved RANSAC based on the Scale Variation Homogeneity——2016
    Computer Vision_33_SIFT:LIFT: Learned Invariant Feature Transform——2016
    Computer Vision_33_SIFT:ORB_An efficient alternative to SIFT or SURF——2012
  • 原文地址:https://www.cnblogs.com/123123-/p/14342847.html
Copyright © 2011-2022 走看看