• 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

Need logic of Removing dulicates from Resultsets

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
reply
    Bookmark Topic Watch Topic
  • New Topic