• 增、删、改、查


    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() + "" });
    }

  • 相关阅读:
    延迟任务
    xxl-job 执行器调度
    Linux查看日志定位问题
    docker 远程连接
    sqlserver的备份和恢复 命令非计划任务
    创建带包含列的索引 sqlserver
    exec sp_executesql (sqlsugar使用中的坑)的坑。执行sql非常慢
    vue elementui的表单设计器
    将docker容器的配置导出为docker-compose.yml
    异步通信,rpc通信的笔记
  • 原文地址:https://www.cnblogs.com/huangzhe1515023110/p/9276120.html
Copyright © 2020-2023  润新知