Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • 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
Marshal
Posts: 34409
346
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
Marshal
Posts: 34409
346
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic