File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Help debug this program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help debug this program" Watch "Help debug this program" New topic
Author

Help debug this program

nash avin
Ranch Hand

Joined: Nov 13, 2003
Posts: 96


The errors I get are as follows......

UserValidator1.java:80: cannot resolve symbol
symbol : variable connection
location: class UserValidator1
boolean isValid = UserValidator1.validateUser(connection, args[
0], args[1]);
^
UserValidator1.java:84: cannot resolve symbol
symbol : variable connection
location: class UserValidator1
connection.close();
^
2 errors
Marcos Stythe
Greenhorn

Joined: Feb 26, 2004
Posts: 4
I think it's because the connection variable you have isn't global but only local to the the place where you define it.

something like that...
[ February 26, 2004: Message edited by: Marcos Stythe ]
nash avin
Ranch Hand

Joined: Nov 13, 2003
Posts: 96
Thanks for the reply I did as you said and this is what the errors I am getting as

UserValidator1.java:80: non-static variable connection cannot be referenced from a static context
boolean isValid = UserValidator1.validateUser(connection, args[0], args[1]);
^
UserValidator1.java:84: non-static variable connection cannot be referenced from a static context
connection.close();
^


Thanks for any help
AS
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
The simple solution is to just add the word "static" to the declaration of connection:
static Connection connection;
However, you should also look at re-designing your code. I say this because I personally feel that the keyword static should only be used when you make a concious choice to do so. Such a choice can only come from understanding what static means. There is plenty of information about it, either here on Java Ranch or on the offical Java Website, so I won't go into those details. If you still need help understanding the difference between static and non-static members, you should start a new thread along those lines.
Layne


Java API Documentation
The Java Tutorial
 
Consider Paul's rocket mass heater.
 
subject: Help debug this program