This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Java in General and the fly likes Assigning values from resultset of db. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Assigning values from resultset of db." Watch "Assigning values from resultset of db." New topic
Author

Assigning values from resultset of db.

Accela Moon
Greenhorn

Joined: Apr 11, 2004
Posts: 20
I have these (same) errors when trying to retrieve values from a resultset from a db.

Errors:

So, if anyone can tell me wus wrong and how to fix it, I will be real thankful.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8935
    
    9


You misspelled the variable dbStatement when you tried to create the ResultSet.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Well, there are all sorts of problems here. The first error is pretty clear: the variable "dbStatement" isn't declared anywhere. Most of the rest are pointing out an admirable burst of imagination on your part. Despite how lovely it might be, the java.sql.ResultSet interface does not sport member variables corresponding to each of your column names. You have to call the methods of this interface to access the data. You would probably benefit greatly from reading this tutorial on using JDBC.
There are some other problems, too: local variables (like "validity") can't be declared public; and the class classHistory, not shown here, doesn't have a constructor with an argument list corresponding to the one you've shown here. But those error messages, again, are fairly clear -- you just have to read them.


[Jess in Action][AskingGoodQuestions]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Assigning values from resultset of db.