• 每日随笔


    今天重写了选课系统,对一个系统需要理清的结构有了更好的认知

    public boolean update(student tea) {
    String sql = "update student set name='" + tea.getName() + "',sex='" + tea.getSex() + "',classes='"
    + tea.getClasses() + "',major='" + tea.getMajor() + "'";
    Connection conn = DBUtil_Student.getConnection();
    boolean f = false;
    PreparedStatement st = null;
    try {
    st = conn.prepareStatement(sql);
    st.executeUpdate(sql);
    f = true;
    } catch (Exception e) {
    e.printStackTrace();
    // TODO: handle exception
    } finally {
    DBUtil_Teacher.close(conn);
    DBUtil_Teacher.close(st);
    }
    return f;

    }

    public boolean Insert(student stu) {
    boolean f = false;
    Connection connection = DBUtil_Student.getConnection();

    PreparedStatement preparedStatement = null;
    try {
    String sql = "insert into student(id,name,sex,classes,major) values ('" + stu.getId() + "','"
    + stu.getName() + "','" + stu.getSex() + "','" + stu.getClasses() + "','" + stu.getMajor() + "')";// 执行语句
    preparedStatement = connection.prepareStatement(sql);// 执行语句的转化
    preparedStatement.executeUpdate(sql);
    f = true;
    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } finally {
    // DBUtil.close(resultSet);
    DBUtil_Student.close(preparedStatement);
    DBUtil_Student.close(connection);
    }
    return f;
    }

  • 相关阅读:
    String
    Map和Set
    js的栈与堆
    js的私有属性
    随便谈一谈原型
    前端页面优化提速
    nth-child和nth-of-type
    重复输出字符串
    闭包
    mongodb内嵌文档的查询
  • 原文地址:https://www.cnblogs.com/buxiang-Christina/p/14158865.html
Copyright © 2020-2023  润新知