• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need logic of Removing dulicates from Resultsets  RSS feed

 
Yugandhar Ghanta
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need logic for removing duplicates from Resultsets. I need to write it in our code bcz here my DB is not supporting DISTINCT functionality. I mean, it should work how Distinc keyword works for all the columns in SQL.
Can any one please help.

Thanks in advance...
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't use abbreviations such as bcz in your posts. For many users english is a second language and it will make things harder for them.

As for your question. Simply create a JavaBean Object that you store the result from your database in, one object per row.
Override hashCode and equals to provide a mechanism to check for equality. Then add all beans to a Set. Voila, dublications are removed.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yugandhar Ghanta wrote:Hi,
I need logic for removing duplicates from Resultsets. I need to write it in our code bcz here my DB is not supporting DISTINCT functionality. I mean, it should work how Distinc keyword works for all the columns in SQL.
Can any one please help.

Thanks in advance...

Seriously?! Which database are you using? And does it support "group by" clauses?
 
Yugandhar Ghanta
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul and Sebastian Janisch for your quick reply.

Here, i am getting data from Excel sheet.Simple Select and Update queries working fine, But queries with Distinct , GroupBy etc ...are not working properly..it is giving some syntax erors.

Anyhow, the solution given by Sebastian Janisch is good and i will implement that.

Thanks once again....
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!