zoukankan      html  css  js  c++  java
  • 每周总结

    写了自测题中的图书管理系统,对写代码的思路大概条理清楚了,但是熟练度还是不够

    public boolean delete(int idr, int idb, String time) {
    String sql = "delete from jieyue where idr='" + idr + "' and idb='" + idb + "' and date='" + time + "'";
    boolean f = false;
    Connection conn = DBUtil_reader.getConnection();
    PreparedStatement st = null;
    try {
    st = conn.prepareStatement(sql);
    st.executeUpdate(sql);
    f = true;
    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } finally {
    DBUtil_reader.close(conn);
    DBUtil_reader.close(st);
    }
    return f;
    }

    public boolean updateday(book book) {
    int a = book.getNumber() - 1;
    String sql = "update book set number='" + a + "' where id = '" + book.getId() + "'";
    Connection conn = DBUtil_book.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_book.close(conn);
    DBUtil_book.close(st);
    }
    return f;
    }

    public boolean updateday2(book book) {
    int a = book.getNumber() + 1;
    String sql = "update book set number='" + a + "' where id = '" + book.getId() + "'";
    Connection conn = DBUtil_book.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_book.close(conn);
    DBUtil_book.close(st);
    }
    return f;
    }

    public List<book> select() {
    String sql = "select * from book";
    Connection connection = DBUtil_book.getConnection();
    PreparedStatement st = null;
    List<book> list = new ArrayList<>();
    ResultSet rs = null;
    book stuid = null;
    try {
    st = connection.prepareStatement(sql);
    st.executeQuery(sql);
    rs = st.executeQuery(sql);
    while (rs.next()) {
    System.out.println("1");
    int id = rs.getInt("id");
    String name = rs.getString("name");
    String peo = rs.getString("peo");
    String chuban = rs.getString("chuban");
    int number = rs.getInt("number");
    stuid = new book(id, name, peo, chuban, number);
    System.out.println("2");
    list.add(stuid);
    }
    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } finally {
    DBUtil_book.close(rs);
    DBUtil_book.close(st);
    DBUtil_book.close(connection);
    }
    return list;
    }

  • 相关阅读:
    light_oj 1197 区间素数筛
    light_oj 1213
    light_oj 1220 素数分解
    bestcoder#43 1002 在数组中找两个数的和取模的最大值 二分
    6月7日 bc总结
    省赛总结
    二分图最大点权独立集 二分图最大点权覆盖
    终于能理解kmp算法了
    hduoj2087 统计串t在串s中出现的次数,重叠不算 KMP
    带权二分图的最大权匹配 KM算法模版
  • 原文地址:https://www.cnblogs.com/buxiang-Christina/p/14159124.html
Copyright © 2011-2022 走看看