• Post Reply Bookmark Topic Watch Topic
  • New Topic

Not Quite sure how there is a SQLException on this line...

 
Michael Paul
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to just get the value of a column in a DB that stores an int. The value is not null. I have tried both using a column name and index number and with both I get a SQLException error. This is the code:



The line I am getting the error on is:




Anyone have an idea as to why this would be happening? All help would be appreciated.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36032
432
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael,
JDBC requires you call rs.next() before rs.getXXX(). A typical idiom is:
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36032
432
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that we have a forum just for JDBC questions up near the top of the forum list. I'll move this for you.
 
Michael Paul
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much, sometimes I shock myself with how I overlook small things! I new that you had to do rs.next() and for some reason refused to think of that...Thank you very much for your help!

Michael
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!