• 2021.5.6


    今日学习进度:

      第一天  第二天 第三天  第四天  第五天 
    所花时间(小时) 4.5        
    代码量(行) 500        
    博客量(篇) 1        
    了解到的知识点 顶会热词分析1      

    今天的任务是讲爬取到的论文相关内容显示出来:

    先写Java类:

    Dao.java

    package classes;
    
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.LinkedHashMap;
    import java.util.List;
    import java.util.Map;
    import java.util.stream.Collectors;
    
    public class Dao {
        public List<lunwenBean> getselectlunwen(String a,String b,String c) throws SQLException{
            List<lunwenBean> list=new ArrayList<>();
            lunwenBean bean=null;
            String sql="select * from xiangxi where abstract like '%"+a+"%' and title like '%"+b+"%' and zuozhe like '%"+c+"%'";
            sql=sql+" order by time desc ";
            System.out.println("SQL="+sql);
            Connection conn =Dbutil.getConnection();
            Statement st=null;
            ResultSet rs=null;
            try {
                st=conn.createStatement();
                st.executeQuery(sql);
                rs=st.executeQuery(sql);
                while(rs.next()) {
                    String title=rs.getString("title");
                    String zhaiyao=rs.getString("abstract");
                    String zuozhe=rs.getString("zuozhe");
                    String lianjie=rs.getString("link");
                    String time=rs.getString("time");
                    bean=new lunwenBean(title,zhaiyao,zuozhe,lianjie,time);
                    list.add(bean);
                   
            }
            } catch (SQLException e) {
                e.printStackTrace();
            }
            finally{
                Dbutil.close(st, conn);
            }
            return list;
            
        }
        public static Map<String,Integer> getrc()
        {
            int tnumi=0;
            String sql="select * from xiangxi ";
            Map<String, Integer>map= new HashMap<String, Integer>();
            Map<String, Integer>results= new LinkedHashMap<String, Integer>();
            Connection conn =Dbutil.getConnection();
            Statement st=null;
            ResultSet rs=null;
            try {
                st=conn.createStatement();
                st.executeQuery(sql);
                rs=st.executeQuery(sql);
                while(rs.next())
                {
                    String keywords=rs.getString("title");
                    keywords=keywords.substring(1, keywords.length());
                    String[] split = keywords.split(" ");
                    for(int i=0;i<split.length;i++)
                    {
                        if(map.get(split[i])==null)
                        {
                            map.put(split[i],1);
                        }
                        else
                        {
                            map.replace(split[i], map.get(split[i])+1);
                            
                        }
                    }   
                    
                    tnumi++;                   
                }
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
           
           // System.out.println("of的个数为"+map.get("of")+"MAP个数"+map.size());
            Dbutil.close(rs, st, conn);
            map.entrySet()                
            .stream()               
            .sorted((p1, p2) -> p2.getValue().compareTo(p1.getValue()))                
            .collect(Collectors.toList())
            .forEach(ele -> results.put(ele.getKey(), ele.getValue()));
            return results;
        }
    }

    demBean.java

    package classes;
    
    public class demBean {
        private String andorno;
        private String xuanze;
        private String neirong;
        private String jingmo;
        
        public demBean(String andorno, String xuanze, String neirong, String jingmo) {
            super();
            this.andorno = andorno;
            this.xuanze = xuanze;
            this.neirong = neirong;
            this.jingmo = jingmo;
        }
        public String getAndorno() {
            return andorno;
        }
        public void setAndorno(String andorno) {
            this.andorno = andorno;
        }
        public String getXuanze() {
            return xuanze;
        }
        public void setXuanze(String xuanze) {
            this.xuanze = xuanze;
        }
        public String getNeirong() {
            return neirong;
        }
        public void setNeirong(String neirong) {
            this.neirong = neirong;
        }
        public String getJingmo() {
            return jingmo;
        }
        public void setJingmo(String jingmo) {
            this.jingmo = jingmo;
        }
        @Override 
        public String toString() {
            return andorno+xuanze+neirong+jingmo;
        }
    }

        写了函数也是无法显示,明天继续。

  • 相关阅读:
    弱爆程序员的特征值
    快捷渐变效果
    做事务性的发布数据库日志会越来越大
    判断MS SQLSERVER临时表是否存在
    SQLite实现加密
    CentOS6.4下安装TeamViewer8
    安装CDT
    CentOS中安装Courier New字体
    VS2012的Windows程序不显示DOS窗口
    log4cpp安装使用
  • 原文地址:https://www.cnblogs.com/marr/p/14905759.html
Copyright © 2020-2023  润新知