• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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....
 
What do you have in that there bucket? It wouldn't be a tiny ad by any chance ...
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic