February 14 learning record

1, recite the words: finite limited, design, plan merely just, but the norm standards, specifications, guidelines soul soul, energy faculty in order; School of congress (on behalf of) the Assembly hinder preventing, hindering or a loaf of bread outfit appliances, institutional wound trauma , wound alloy alloy waterproof waterproof, water-resistant immediate immediate, real-time clutch catch, gripped, master salesman salesman, salesman stem stalks, stems cruel cruel, cruel dump dump, dump restless restless; restless this is such; above strain tension; tension; sprain pregnant pregnant, gave birth to a session of the conversation, the conversation

2, the data in the file will be stored in mysql, Capital Window from crawling up over twelve thousand pieces page letter detailed data. Until January 2015

 

com.lq.dao Package; 

Import com.lq.bean.XinJian; 
Import com.lq.file.LocalFile; 

Import the java.sql. * ; 
Import java.util.List; 

public class AddToMySql 
{ 
    Private static String the DriverName = "COM .mysql.jdbc.Driver " ; 
    Private UName static String =" root " ; 
    Private static String Upwd =" root " ; 
    Private static String the Url =" jdbc:? MySQL: //192.168.25.1: 3306 / = to true Xinjian useUnicode & characterEncoding = . 8-UTF " ; 
    public Boolean Exit (String ID)    // The Id returns true if the query whether there exists, returns false absent 
    {
         //System.out.println (Query (the above mentioned id)); 
        return Query (the above mentioned id) == 1? To true : false ; 
    } 
    public int Query (String Id)    // query whether there is; there is return 1; 0 presence or absence of return; 
    { 
        Xinjian Xinjian = null ; 
        Connection Conn = null ; 
        the PreparedStatement pstmt = null ; 
        the ResultSet Result = null ;
         int COUNT = -1 ;
         the try { 
            the Class.forName (the DriverName); 
            Conn =DriverManager.getConnection(Url, UName, Upwd);
            String sql="select count(*) from xinjian where Id=?";
            pstmt= conn.prepareStatement(sql);
            pstmt.setString(1,Id);
            result=pstmt.executeQuery();
            if(result.next()){
                count=result.getInt(1);
                System.out.println("已存在");
            }
            if(count>0)
            return count;
        }
        catch(ClassNotFoundException e)
        {
            e.printStackTrace();
            return count;
        }
        catch (SQLException e)
        {
            e.printStackTrace();
            return count;
        }
        catch(Exception e)
        {
            e.printStackTrace();
            return count;
        }
        finally {
            try {
                if(result!=null) result.close();
                if(pstmt!=null) pstmt.close();
                if(conn!=null) conn.close();
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }
        }
        return count;
    }
    public boolean Add(XinJian xinJian)   //添加信息
    {
        Connection conn=null;
        PreparedStatement pstmt=null;
        try {
            AddToMySql addToMySql=new AddToMySql();
            //System.out.println(addToMySql.exit(xinJian.getId()));
            if(addToMySql.exit(xinJian.getId())!=true) {
                //System.out.println("2");
                Class.forName(DriverName);
                conn = DriverManager.getConnection(Url, UName, Upwd);
                String sql = "insert into xinjian(Id,typet,massage,statue,send_time,addresser,asker,details,answering,answer_time,reply) values(?,?,?,?,?,?,?,?,?,?,?)";
                pstmt = conn.prepareStatement(sql);
                pstmt.setString(1, xinJian.getId());
                pstmt.setString(2, xinJian.getType());
                pstmt.setString(3, XinJian.getMassage ()); 
                pstmt.setString ( . 4 , xinJian.getStatue ()); 
                pstmt.setString ( . 5 , xinJian.getSend_time ()); 
                pstmt.setString ( . 6 , xinJian.getAddresser ()); 
                pstmt.setString ( . 7 , xinJian.getAsker ()); 
                pstmt.setString ( . 8 , xinJian.getDetails ()); 
                pstmt.setString ( . 9 , xinJian.getAnswering ()); 
                pstmt.setString ( 10 , xinJian.getAnswer_time ()); 
                pstmt .setString ( . 11 , xinJian.getReply ()); 

                int connt =pstmt.executeUpdate ();
                 IF (connt> 0 ) { 
                    System.out.println ( "saved successfully" );
                     return  to true ; 

                } 
                the else { 
                    System.out.println ( "exists" );
                     return  to false ; 
                } 
            } 
            the else  return  to false ; 
        } 
        the catch (a ClassNotFoundException E) 
        { 
            e.printStackTrace (); 
            return  to false ;   // abnormalities
        }
        catch(SQLException e)
        {
            e.printStackTrace();
            return false;
        }
        catch(Exception e)
        {
            e.printStackTrace();
            return false;
        }
        finally
        {
            try
            {
                if(pstmt!=null){
                    pstmt.close();
                    conn.close();
                }
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        }

    }
    public void Run(){
        try {
            LocalFile localFile=new LocalFile();
            AddToMySql addToMySql=new AddToMySql();
            String []  strs = localFile.read_xinjian_local("xinjian.txt");
            String[] str=null;
            for(int i=0;i<strs.length;i++){
                str=strs[i].split("&&");
                XinJian xinJian=null;

//                System.out.println(str[0]+str[10]);
//               System.out.println("------------------------------------------------------");
                xinJian=new XinJian(str[0],str[1],str[2],str[3],str[4],str[5],str[6],str[7],str[8],str[9],str[10]);
                addToMySql.Add(xinJian);
               // System.out.println(xinJian.toString());
            }
            //System.out.println(str.length);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args){
        AddToMySql addToMySql=new AddToMySql();
        //addToMySql.exit("AH19080800081");
        addToMySql.Run();
        System.out.println("finish");
    }

}

 

public String[] read_xinjian_local(String files) throws Exception
    {
        File file =new File("outfile"+File.separator+files);
        FileReader locla_file=new FileReader(file);
        BufferedReader input=new BufferedReader(locla_file);
        char bb[]=new char[1024];
        String []read_all=null;
        String str=null;
        int len=-1;
        List<String> reads=new ArrayList<String>();
        while((len=input.read(bb))!=-1){
            String read=new String(bb,0,len);
            reads.add(read);

        }
        StringHandle stringHandle=new StringHandle();
        str=stringHandle.ListToString(reads);
        read_all=str.split("\\r?\\n");
        return read_all;
    }

 

 

Simple to learn Ajax technology: https://www.bilibili.com/video/av29885002   24-and 25 sets

Learning Echart: https://www.bilibili.com/video/av73796938

3. Problems encountered:

  1, crawling letter also identified the property value data today includes crawling fields div, and some pages have spaces, and some pages with no spaces; I ended up crawling each data are added to determine when a way can not be used data of the second crawling manner.

  2, to read the file today taken the contents of each letter, with the results stored previously $$ is divided, when the result can not be effectively divided by the split function, then the final test for splitting a plurality of characters after the newline; well, there are some details of the letter so many words, the length of the varchar when I set the mysql into 1000 is not enough, also recognized the great length of the varchar data can be stored.

4, tomorrow plan: continue to learn Echart, the mysql data analysis and graphically display

Guess you like

Origin www.cnblogs.com/lq13035130506/p/12310180.html