Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and the fly likes Cannot find symbol Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Cannot find symbol" Watch "Cannot find symbol" New topic
Author

Cannot find symbol

Joe Lemmer
Ranch Hand

Joined: Oct 24, 2008
Posts: 171
Hi there

I'd be grateful if someone could point out to me where I'm going wrong with the following code. I have one very basic JDBC test program that seems to work fine, but another very similar program where I have the following errors when I try to compile:

cannot find symbol:
symbol: class Statement
location: class Jdbc11
Statement stmt;

cannot find symbol:
symbol: class Connection
location: class Jdc11
Connection con = DriveManager.getConnection("jdbc:mysql://localhost/mysql", "root", "secret");

cannot find symbol:
symbol: variable DriveManager
loction: class Jdbc11
Connection con = DriveManager.getConnection("jdbc:mysql://localhost/mysql", "root", "secret");

Here's the full code for the program that does NOT work:



and just for comparison, here's the code for the program that does work:



Cheers

Joe Lemmer


OCPJP 85%
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42935
    
  68
Not sure about the first two, but the last one is explained by a spelling mistake.
Joe Lemmer
Ranch Hand

Joined: Oct 24, 2008
Posts: 171
Hi Ulf

Thanks for the reply.

I've changed the spelling mistake, but I still get the same three errors.

My other program still works though. Very Confusing!

Regards

Joe
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42935
    
  68
Strange. I just copied it verbatim, and it compiles fine (after correcting the typo).

It's especially odd since Connection, Statement and DriverManager are all in the same package, so one would expect the compiler to be able to find all of them, or none.
Joe Lemmer
Ranch Hand

Joined: Oct 24, 2008
Posts: 171
Right. Well at least it compiles on your machine Ulf. It must be something very basic that I'm missing. Think I'll try just typing it in again.

Thanks for your help. :-)
[ November 08, 2008: Message edited by: Joe Lemmer ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot find symbol