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

  • 相关阅读:
    IOC(inverse of Control)控制反转(依赖注入)思想
    学习Ajax技术总结
    设计差异引发WebServices 安全性问题
    XML与Webservices相关的安全问题概述
    XML与Webservices相关的安全问题概述
    设计差异引发WebServices 安全性问题
    Webservice测试方案(目录及下载链接)
    XML与Webservices相关的安全问题概述
    设计差异引发WebServices 安全性问题
    构建安全的 Web Services
  • 原文地址:https://www.cnblogs.com/buxiang-Christina/p/14159124.html
Copyright © 2011-2022 走看看