jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes Not Quite sure how there is a SQLException on this line... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Not Quite sure how there is a SQLException on this line..." Watch "Not Quite sure how there is a SQLException on this line..." New topic
Author

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

Michael Paul
Greenhorn

Joined: Mar 29, 2008
Posts: 14
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

Joined: May 26, 2003
Posts: 32645
    
216

Michael,
JDBC requires you call rs.next() before rs.getXXX(). A typical idiom is:


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32645
    
216

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

Joined: Mar 29, 2008
Posts: 14
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not Quite sure how there is a SQLException on this line...
 
It's not a secret anymore!