About importing data to Excel and deduplication the database and the imported Excel file

Source: Internet
Author: User

Tag: equals code uses element delete to perform dev repeat hash

To insert into the database go to weight:

1. Iterate through the list you have read

2. Get the data you need to query before you insert the method into the database, execute the Query method

1 devlist=devicedao.finddevice (Device.getrfid ()); 2              if (Devlist.size () >0) {3                       messagestr = "Duplicate data, please re-import!" "; 4 5              } Else {6                       devicedao.save (device); 7                         MESSAGESTR = "Data import successful!" "; 8                     }

To the imported Excel file to go to the weight:

(1) The elements in the loop list are deleted repeatedly

1 //devlist for cyclic reading2  for(inti = 0; I < Devlist.size ()-1; i + + )  {       3        for(intj = devlist.size ()-1; J > i; J-- )  {       4            if(Devlist.get (j). Equals (Devlist.get (i))) {5 Devlist.remove (j); 6             }        7         }        8}

(2) Remove duplicate elements by HashSet

1 // as above, list is the list for getting to Excel data 2 New HashSet (list);    3 list.clear ();    4 List.addall (h);

(3) Traverse list to see if the data exists and use contain

1         New ArrayList ();   2          for (int i=0;i<list.size (); i++) {  3             if(!  Listtemp.contains (List.get (i))) {  4                listtemp.add (list.get (i   )); 5             }  6         }  

About importing data to Excel and deduplication the database and the imported Excel file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.