• 每日日报2021.2.2


    今天完成内容:

    开发家庭小账本

    1.编写代码

    public List<User> ResearchName(String name){
    List<User> list = new ArrayList<User>();
    Connection conn = DbHelper.getConnection();
    String sql = "select * from userno where username = ?";
    try {
    PreparedStatement pst = conn.prepareStatement(sql);
    pst.setString(1, name);
    ResultSet rst = pst.executeQuery();
    while(rst.next()) {
    User user = new User();
    user.setId(rst.getInt("id"));
    user.setUsername(rst.getString("username"));
    user.setUserused(rst.getString("userused"));
    user.setUsermoney(rst.getString("usermoney"));
    user.setUsedate(rst.getDate("usedate"));
    list.add(user);
    }
    rst.close();
    pst.close();
    } catch (SQLException e) {
    // TODO 自动生成的 catch 块
    e.printStackTrace();
    }
    return list;
    }

    public User ResearchId(int id) {
    Connection conn = DbHelper.getConnection();
    String sql = "select * from userno where id = ?";
    ResultSet rst = null; 

    User user = new User();
    try {
    PreparedStatement pst = conn.prepareStatement(sql);
    pst.setInt(1, id);
    rst = pst.executeQuery();
    while(rst.next()) {
    user.setId(rst.getInt("id"));
    user.setUsername(rst.getString("username"));
    user.setUserused(rst.getString("userused"));
    user.setUsermoney(rst.getString("usermoney"));
    user.setUsedate(rst.getDate("usedate"));
    }
    rst.close();
    pst.close();
    } catch (SQLException e) {
    // TODO 自动生成的 catch 块
    e.printStackTrace();
    }

    // TODO 自动生成的方法存根
    return user;
    }

    public List<User> showAll(){
    List<User> list = new ArrayList<User>();
    Connection conn = DbHelper.getConnection();
    String sql = "select * from userno";
    try {
    PreparedStatement pst = conn.prepareStatement(sql);
    ResultSet rst = pst.executeQuery();
    while(rst.next()) {
    User user = new User();
    user.setId(rst.getInt("id"));
    user.setUsername(rst.getString("username"));
    user.setUserused(rst.getString("userused"));
    user.setUsermoney(rst.getString("usermoney"));
    user.setUsedate(rst.getDate("usedate"));
    list.add(user);
    }
    rst.close();
    pst.close();
    } catch (SQLException e) {
    // TODO 自动生成的 catch 块
    e.printStackTrace();
    }
    return list;
    }

    遇到问题:

    无,可以实现查询功能

    明日目标:

    学习Android studio的开发

  • 相关阅读:
    POJ 1611 : The Suspects (普通并查集)
    深入解析 Dubbo 3.0 服务端暴露全流程
    智能搜索推荐一体化营收增长解决方案
    云上应用系统数据存储架构演进
    EMR on ACK 全新发布,助力企业高效构建大数据平台
    介绍一下闭包和闭包常用场景?
    BFC
    高斯消元学习笔记
    云虚拟主机如何设置域名解析
    Centos7.3安装openJDK
  • 原文地址:https://www.cnblogs.com/leiyu1905/p/14905640.html
Copyright © 2020-2023  润新知