• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Source code for removing duplicate records in the excel sheet !!

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I need source code for removing duplicate records while reading the date from Excel Sheet and updating the data in DB..

i.e I dont want duplicate records in the DB Table.

Thanks
 
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sathishi kumarar wrote:Hi All,

I need source code for removing duplicate records while reading the date from Excel Sheet and updating the data in DB..

i.e I dont want duplicate records in the DB Table.

Thanks



Create a primary key in your DB, let there be exception, which you can catch. Is there anything still wrong?
 
sathishi kumarar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Is this is the only way to check for duplicates or we can use any Logic inside the JAVA Code for checking duplicate records.

Thanks
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sathishi kumarar wrote:Is this is the only way to check for duplicates or we can use any Logic inside the JAVA Code for checking duplicate records.


Well, first you need to have a "record" (by which I presume you mean an Excel row). If you're using Apache POI, you need to find out if it already has such a class (I suspect it does).

Second, you need some way to check if they are "equal", and again, POI may be able to do that for you already.

Alternatively, you could write your own Record class (maybe as a wrapper to POI's own, if it has one), create an equals() and hashCode() method for it, and try loading the entire spreadsheet into a HashSet. That'll soon highlight any "duplicates" you have.

Winston
reply
    Bookmark Topic Watch Topic
  • New Topic