| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取总计 |
| | | * |
| | | * @param tableName 表名称 |
| | | * @return {@link Double} |
| | | */ |
| | | public static Double getTotal(String tableName) { |
| | | // 1. 创建SQLite数据库连接 |
| | | try (Connection conn = DriverManager.getConnection("jdbc:sqlite:rainfall.db")) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | public static Integer getDuration(String tableName) { |
| | | /** |
| | | * @param tableName 表名称 |
| | | * @return {@link Integer} |
| | | */ |
| | | public static Integer getDuration(String tableName) throws SQLException { |
| | | // // 1. 连接数据库 |
| | | // try (Connection conn = DriverManager.getConnection("jdbc:sqlite:rainfall.db")) { |
| | | // // 2. 执行查询语句 |
| | | // String queryDataSql = "SELECT duration FROM " + tableName; |
| | | // try (PreparedStatement pstmt = conn.prepareStatement(queryDataSql)) { |
| | | // ResultSet rs = pstmt.executeQuery(); |
| | | // while (rs.next()) { |
| | | // // 获取总和 |
| | | // return rs.getInt("duration"); |
| | | // } |
| | | // } catch (SQLException e) { |
| | | // throw new RuntimeException(e); |
| | | // } |
| | | // } catch (SQLException e) { |
| | | // System.err.println("SQLite连接失败: " + e.getMessage()); |
| | | // } |
| | | |
| | | // 目前先根据文件的内容,手动给值,后续使用解析文件内容中的时间 |
| | | // TODO: 2024/12/27 目前先根据文件的内容,手动给值,提高处理速度。后续使用解析文件内容中的时间。 |
| | | return 1440; |
| | | } |
| | | |
| | | } |