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 myCon not recognised Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "myCon not recognised" Watch "myCon not recognised" New topic
Author

myCon not recognised

Ian Cockcroft
Ranch Hand

Joined: Apr 05, 2001
Posts: 46
Hi all.
The following code is just a little utility to read data from a DAT file and put it in an access database.

(Its nothing special, I'm sure you guys have a better way of doing this.)
I am getting an error when I compile that it doesnt recognise myCon.
------- Compiler Output ------
UpdateAccessUtility.java:58: cannot resolve symbol
symbol : variable myCon
location: class UpdateAccessUtility
Statement stm = myCon.createStatement();

Any ideas? I have declared it in the same class.
Thanks guys
regards
Ian


- Make it idiot proof and they'll make a better idiot!
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Ian
You declare adn intialize myCon in a try block so that the variable is local to that block. Move the declaration outside of the block and you'll be ok with that part. You're going to need to catch the SQLException that can be thrown by that statement though. All you catch is an IOException after that try block.
hope that helps


Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: myCon not recognised
 
Similar Threads
retrieving value from a text box
reading CSV file
Readind and Writing Contents of JTable in txt file
Problem with StringBuffer
JDBC Connection