• 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

PostGreSQL resultset.next()

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,

I have the following code:



My table PEOPLE is empty but why I call rs.next() with postgresql, this instruction return true and not false ... instead with Oracle, MSSQL, ... previous instruction return correctly false ...
I have try several JDBC driver of postgresql but nothing.

Any one have a idea ?

best regards,

Adrien
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it returns true, I'd suggest trying to access the fields in that row and see what happens. Chances are that the table is not empty after all.
 
Adrien Ruffie
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I actually tried to access the data and it give me an id: 0000000001 which doesn't exist ... this simply incremented the next() with the first generation of ID ...
very strange ... it's the default behavior ?
 
Martin Vashko
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, a SELECT statement should return the data as they exist in the database. Of course, there is still a possibility of a bug in the JDBC driver, but...

What I still think is that you're looking at another table which is empty, but in Java selecting from a different table which contains data. Are you using the same user in the JDBC code and whatever tool you use to look in the database? Couldn't there be a synonym, view or other thing which would cause the tables to be mixed up?

Besides, the table probably contains fields other than ID. Did you try to print out these? If they contain meaningful texts (names, for example), the table is probably real - it would be highly unlikely that a bug in a JDBC driver would cause some meaningful names and texts to appear out of nowhere.
 
Adrien Ruffie
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found the problem, a mistake into db connection url:

jdbc:postgresql://postgres-server:5432:TestBase was use

I change to:
jdbc:postgresql://postgres-server:5432/TestBase

And I work correctly, but it's strange that JDBC driver doesn't throws
a exception with a bad url format ...
 
reply
    Bookmark Topic Watch Topic
  • New Topic