zoukankan      html  css  js  c++  java
  • 每日学习

    今天继续个人作业2,

    对于获取的数据的处理:

    public Map<String,Integer> getallmax()
        {
            String sql="select * from cvpr";
            Map<String, Integer>map=new HashMap<String, Integer>();
            Map<String, Integer>sorted=new HashMap<String, Integer>();
            Connection con=null;
            Statement state=null;
            ResultSet rs=null;
            try {
    			con=Util.getConnection();
    		} catch (SQLException e3) {
    			// TODO Auto-generated catch block
    			e3.printStackTrace();
    		}
            try {
                state=con.createStatement();
                rs=state.executeQuery(sql);
                while(rs.next())
                {
                    String keywords=rs.getString("keywords");
                    String[] split = keywords.split(",");
                    for(int i=0;i<split.length;i++)
                    {
                        if(map.get(split[i])==null)
                        {
                            map.put(split[i],0);
                        }
                        else
                        {
                            map.replace(split[i], map.get(split[i])+1);
                        }
                    }
                }
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            Util.close( con, state,rs);
            sorted = map
                    .entrySet()
                    .stream()
                    .sorted(Collections.reverseOrder(Map.Entry.comparingByValue()))
                    .collect(
                    		Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e2,
                                    LinkedHashMap::new));
            return sorted;
        }
    
    作者:哦心有
    本文版权归作者和博客园共有,欢迎转载,但必须给出原文链接,并保留此段声明,否则保留追究法律责任的权利。
  • 相关阅读:
    清理iOS工程里无用的图片,可瘦身ipa
    NSTimer内存泄漏导致控制器不调用dealloc
    iOS面试题 -总结 ,你的基础扎实吗?
    Xcode找不到模拟器出现"My Mac"
    前端开发
    并发编程&数据库
    数据库
    4.2
    4.5
    4.4
  • 原文地址:https://www.cnblogs.com/haobox/p/14911159.html
Copyright © 2011-2022 走看看