• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
sathishi kumarar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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
 
Akhilesh Trivedi
Ranch Hand
Posts: 1603
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Winston Gutkowski
Bartender
Pie
Posts: 10422
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic