zoukankan      html  css  js  c++  java
  • 增、删、改、查

    public int doAdd(Reply reply) {
    String sql = "insert into reply values(null,?,?,?,?,?,?)";
    return this.getJdbc().executeUpdate(
    sql,
    new String[] { reply.getTitle(), reply.getContent(),
    reply.getPublishtime().toString(),
    reply.getModifytime().toString(),
    reply.getTopicid() + "", reply.getUid() + "" });

    }

    ------------------------------------------------------------------------------------------------

    public int doDelete(String replyid) {
    String sql = "delete from reply where replyid=" + replyid;
    return this.getJdbc().executeUpdate(sql, null);
    }

    ---------------------------------------------------------------------------------------------------

    public List<Board> findAll(){
    List<Board> list=new ArrayList<Board>();
    //创建sql语句
    String sql="select * from board";
    //执行查询
    ResultSet rs=this.getJdbc().executeQuery(sql, null);
    //遍历
    try {
    while(rs.next()){
    Board board=new Board();
    board.setBoardid(rs.getInt("boardid"));
    board.setBoardname(rs.getString("boardname"));
    list.add(board);
    }
    } catch (SQLException e) {
    e.printStackTrace();
    }finally{
    this.closeResource();
    }
    return list;
    }

    --------------------------------------------------------------------------------------------------

    public int doUpdate(Reply reply) {


    String sql = "update reply set title = ?, content = ?, modifytime = ? where replyid = ?";


    return this.getJdbc().executeUpdate(sql, new String[] { reply.getTitle(), reply.getContent(),
    reply.getModifytime().toString(), reply.getReplyid() + "" });
    }

  • 相关阅读:
    python数据类型-字典的练习
    python数据类型-元祖和字典类型、hash函数
    python数据类型-字符串
    python数据类型-列表练习
    python数据类型-列表
    iOS 熟悉CASharpLayer
    iOS 点击tableView的cell,让其滚到屏幕顶部
    iOS pop动画之弹性动画的基本使用
    iOS Json解析框架之MJExtension使用详解
    iOS pop动画之衰减动画的基本使用
  • 原文地址:https://www.cnblogs.com/huangzhe1515023110/p/9276120.html
Copyright © 2011-2022 走看看