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;
    }

  • 相关阅读:
    什么是接口测试?怎样做接口测试?
    python下批量执行多条py文件的方法
    Jmeter运行报错software caused connection abort:recv failed
    性能测试一般容易出现瓶颈点
    性能测试流程规范(较好文档)
    Jmeter代理录制获取登录参数_移动端设置代理
    Http请求与WebSocket请求区别(WebSocket协议简析)
    JSONObject方法提取响应数据中的值
    Jmeter学习资料、控件下载地址大全
    图解IntelliJ IDEA 13版本对Android SQLite数据库的支持
  • 原文地址:https://www.cnblogs.com/buxiang-Christina/p/14159124.html
Copyright © 2011-2022 走看看