• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Resultset's getint method in If condition

 
Ays impec
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic