| Author |
Source code for removing duplicate records in the excel sheet !!
|
sathishi kumarar
Greenhorn
Joined: Dec 09, 2011
Posts: 4
|
|
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
Joined: Jun 22, 2005
Posts: 1493
|
|
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?
|
Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
|
 |
sathishi kumarar
Greenhorn
Joined: Dec 09, 2011
Posts: 4
|
|
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
Joined: Mar 17, 2011
Posts: 4761
|
|
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
|
Isn't it funny how there's always time and money enough to do it WRONG?
|
 |
 |
|
|
subject: Source code for removing duplicate records in the excel sheet !!
|
|
|