This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help debug this program
 
Similar Threads
Please help debug this program
help please as to how to go about doing this
Need Help Pulling Data From Oracle Table (Newby)
Please help me out with this
SQL: Searching a database