Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!
  • 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

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: 21694
101
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: 21694
101
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
Rancher
Posts: 3989
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.
 
What's wrong? Where are you going? Stop! Read this tiny ad:
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!