File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC 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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29220
    
135

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


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29220
    
135

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...
 
Similar Threads
running the result from the end
Exception in thread "main"
JDBC: What is the concrete class that implements the jdbc interfaces
Retrieve a column value from ArrayList
Tryin' to create a small MS SQL Java Application