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的开发

  • 相关阅读:
    关键字 final
    继承中的构造方法
    方法的重写
    使用tar 和 split 将文件打包、压缩并分割成指定大小
    标准Web系统的架构分层
    Android的安全机制 1 -- 老罗
    Android 在 SElinux下 如何获得对一个内核节点的访问权限
    移动数据 流程分析
    ARM Linux 3.x的设备树(Device Tree)
    如何分析Android的Log
  • 原文地址:https://www.cnblogs.com/leiyu1905/p/14905731.html
Copyright © 2011-2022 走看看