• 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

JDBC doesn't retrieve all the results available in the MSSQL database

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys!

I really have no clue what's going on at all.. I've noticed lately how sometimes I won't get as many results from a query in Java as I get from doing the exact same SQL query from within the MSSQL Server Management Studio.
I've tried to include the MSSQL manager output and the java output, with the output data omitted. And my class that connects to the database is also pasted in there.
Basically the same query retrieves 26 results from within the MSSQL manager and only 16 from java ?!
Please point me in the right direction here

Thanks in advance !

Edited to remove screenshot: please post text.
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Before you edited your post, you had two different select statements. One had "where key=XXXX" and the other had "where key=YYYY"
 
Ranch Hand
Posts: 470
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would suggest to post code by using code tags, instead of screen shots.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm removing the screenshot. Please post text.
 
Alexander Selling
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tom Reilly wrote:Before you edited your post, you had two different select statements. One had "where key=XXXX" and the other had "where key=YYYY"



Yeah I noticed that, I just took the picture earlier and happened to paste that one, it is the exact same query though.
I just took the screenshots cause I thought it would make things clearer, seeing how the MSSQL manager gets more results even though the sql syntax is exactly the same.

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now the SQL and JDBC query results...
 
Alexander Selling
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't really know how to describe the output, I'm getting 26 rows of results from the MSSQL manager and only 16 rows from java, I guess I was more asking if you guys had ever experienced anything like it ?
Since it is a very simple query merely a select statement, how could there be a difference ?
I'll give you some more (smaller) screenshots if you'd like ?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I think we've been pretty clear that we want text--this shouldn't be difficult. No, I've never had his issue, but I'm always suspicious of delimited names, and have no idea how they'll interact with the JDBC driver. Have you tried something similar with a non-delimited column name?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read PostTextNotScreenshots.
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assuming that your two queries are the same (which I'm not yet convinced), could you be accessing different databases? different schemas? different user?
 
Alexander Selling
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Have you tried something similar with a non-delimited column name?



Thing is I'm using an MSAccess database that came with a product that the family company bought, so I can't change their column names. However I imported their database into my MSSQL server and changed the column names on my copy of it, and just like you said, it will retrieve less results every time due to the space in the column name, because when I changed it from [KEY 1] to just KEY1, suddenly all the results came just fine. Now I don't know how to solve this, since I can't change the actual database that I want to read from, but at least now I know why

Thanks a lot!
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's even worse than that, because the JDBC-ODBC drivers have a lot of issues, so accessing the ironically-named Access may lead to even *more* troubles :)
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about creating views to "wrap" the tables?
 
Do the next thing next. That’s a pretty good rule. Read the tiny ad, that’s a pretty good rule, too.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic