@Override
    public Map<String, Object> count(String task) {
        MappingConfig config = rdbMapping.get(task);
        MappingConfig.DbMapping dbMapping = config.getDbMapping();
        String sql = "SELECT COUNT(1) AS cnt FROM " + SyncUtil.getDbTableName(dbMapping);
        Connection conn = null;
        Map<String, Object> res = new LinkedHashMap<>();
        try {
            conn = dataSource.getConnection();
            Util.sqlRS(conn, sql, rs -> {
                try {
                    if (rs.next()) {
                        Long rowCount = rs.getLong("cnt");
                        res.put("count", rowCount);
                    }
                } catch (SQLException e) {
                    logger.error(e.getMessage(), e);
                }
            });
        } catch (SQLException e) {
            logger.error(e.getMessage(), e);
        } finally {
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException e) {
                    logger.error(e.getMessage(), e);
                }
            }
        }
        res.put("targetTable", SyncUtil.getDbTableName(dbMapping));

        return res;
    }
@ Override public Map < String , Object > count ( String task ) { MappingConfig config = rdbMapping . get ( task ) ; MappingConfig . DbMapping dbMapping = config . getDbMapping ( ) ; String sql = "SELECT COUNT(1) AS cnt FROM " + SyncUtil . getDbTableName ( dbMapping ) ; Connection conn = null ; Map < String , Object > res = new LinkedHashMap < > ( ) ; try { conn = dataSource . getConnection ( ) ; Util . sqlRS ( conn , sql , rs -> { try { if ( rs . next ( ) ) { Long rowCount = rs . getLong ( "cnt" ) ; res . put ( "count" , rowCount ) ; } } catch ( SQLException e ) { logger . error ( e . getMessage ( ) , e ) ; } } ) ; } catch ( SQLException e ) { logger . error ( e . getMessage ( ) , e ) ; } finally { if ( conn != null ) { try { conn . close ( ) ; } catch ( SQLException e ) { logger . error ( e . getMessage ( ) , e ) ; } } } res . put ( "targetTable" , SyncUtil . getDbTableName ( dbMapping ) ) ; return res ; }
获取总数方法

@param task 任务名, 对应配置名
@return 总数