zoukankan      html  css  js  c++  java
  • 每日日报2021.2.7

    今天完成内容:

    开发家庭小账本:选择项

    1.编写代码

    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"));
    user.setUsed(rst.getString("used"));
    }
    rst.close();
    pst.close();
    } catch (SQLException e) {
    // TODO 自动生成的 catch 块
    e.printStackTrace();
    }
    // TODO 自动生成的方法存根
    return user;
    }
    public int IncomeSum(){
    Connection conn = DbHelper.getConnection();
    String sql = "select * from userno where used = ?";
    String snum = null;
    PreparedStatement pst = null;
    int isum = 0;
    try {
    pst = conn.prepareStatement(sql);
    pst.setString(1, "收入");
    ResultSet rst = pst.executeQuery();
    while(rst.next()) {
    User user = new User();
    user.setUsermoney(rst.getString("usermoney"));
    snum = user.getUsermoney();
    isum = isum + Integer.parseInt(snum);
    }
    rst.close();
    pst.close();
    } catch (SQLException e) {
    // TODO 自动生成的 catch 块
    e.printStackTrace();
    }
    return isum;
    }
    public int ExpendSum(){
    Connection conn = DbHelper.getConnection();
    String sql = "select * from userno where used = ?";
    int esum = 0;
    String snum = null;
    try {
    PreparedStatement pst = conn.prepareStatement(sql);
    pst.setString(1, "支出");
    ResultSet rst = pst.executeQuery();
    while(rst.next()) {
    User user = new User();
    user.setUsermoney(rst.getString("usermoney"));
    snum = user.getUsermoney();
    esum = esum + Integer.parseInt(snum);

    }
    rst.close();
    pst.close();
    } catch (SQLException e) {
    // TODO 自动生成的 catch 块
    e.printStackTrace();
    }
    return esum;
    }

    遇到问题:

    解决大部分问题,还有一些细节未修改

    明日目标:

    学习Android studio的开发

  • 相关阅读:
    Confluence未授权模板注入/代码执行(CVE-2019-3396)
    Python实现批量处理扫描特定目录
    windows10 缺失 msvcp140.dll 解决办法
    nessus 故障处理
    python 处理json数据
    python 实现两个文本文件内容去重
    python3 实现多域名批量访问特定目录(一)
    python 简单的实现文件内容去重
    python 实现爬取网站下所有URL
    php强大的filter过滤用户输入
  • 原文地址:https://www.cnblogs.com/leiyu1905/p/14905731.html
Copyright © 2011-2022 走看看