• 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

Resultset's getint method in If condition

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



Iam working on java JDK7 and Microsoft Access 2007.Basically I want to get the minimum value from the all the columns of row1.But the following code doesnt work. So can anyone tell me what here is going wrong.




So here I get the output the first row each column values that's fine,but when the control enters the for loop the println statement prints the hello only once and the cursor blinks.This indicates the the program has not ended correctly.
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know what the problem is, but this bit:
does nothing. So if there are any exceptions being thrown by the bit you say isn't working, you'll never know about it. Never ignore an exception.
 
Ays impec
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK Metthew
If I use
I get "No data found exception" .
I am sure that this exception is due to the fact that rs.getInt() method didnt find any data in the table columns but the data is already present.Even if i comment out the println method just below rs.next() then the output is that the hello is getting printed twice .My doubt is why is that for loop not printing hello 5 times
 
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
You're using select * - are you sure the query returns (at least) six integer columns? Selecting - and accessing - the columns by name would be much more readable.

I might be wrong, but some really old JDBC drivers required you to read values of the columns from the resultset in the order in which they were selected by the query, and only once. This might also be the case. I'd suggest using a specific JDBC driver for your database - JDBC/ODBC bridge you're using now is known to be inefficient, buggy and will be discontinued in next version of Java.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Martin Vajsar wrote:I might be wrong, but some really old JDBC drivers required you to read values of the columns from the resultset in the order in which they were selected by the query, and only once.



That last bit would explain this. I think there must be enough columns, otherwise it would never manage to print "hello" the first time. But each value is being read 2 or 3 times.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic