Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help debug this program

 
nash avin
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic