• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

distinct clause does not appear to work  RSS feed

 
Ranch Hand
Posts: 147
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Netbeans 8 I have list of isbn's in a file that i read in then call the method to only keep one of each, i do not get any error codes
here is the code for the method


here is the output
97818473964711
97818440856441
97818422315241
97817803306171
97807553494181
97800995146261
97800995253871
97800995741701
97805860553661<<<<<<<<
97805860553662<<<<<<<<
97805860553661<<<<<<<<
97805860553662<<<<<<<<
97805860564931

the indicated ones are duplicates that are not being removed by the distinct clause, can any one tell why ?
 
Sheriff
Posts: 21745
102
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe there is some white space at the end. You can't easily see that when it's printed out without something visually following it. Print something after the values:
 
peter m hayward
Ranch Hand
Posts: 147
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the problem was exactly as Rob Spoor pointed out the  demon white space

thanks for your help
 
Rob Spoor
Sheriff
Posts: 21745
102
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
Master Rancher
Posts: 4077
47
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you're using a PreparedStatement then you really shouldn't be concatenating your SQL together.
It ought to be:


You're also not closing off your statement or result set, which can result in your database running out of resources, eg cursors.
 
Whatever you say buddy! And I believe this tiny ad too:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!