Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Help debug this program

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic