Why do I get a "cannot resolve symbol"

Hi all,
whenever I run my program it always gives me this error :
Mortgage5.java:14: cannot resolve symbol
symbol : class Loan
location: class Mortgage5
Loan theLoan;
^
This program will work in Win 98 and XP but on my other machine running Windows 2000 will not work.
My Mortgage5 class is actually creating an object of another class called Loan which is perfectly fine in other Windows OS but not my 2000, why is that so? I am really puzzled.

Hi Kusek,
here is my code that works on other OS but not 2000.
import java.text.*;
public class Mortgage5
{     public static void main (String args[])
     {     double thePrincipal;
          double theRate;
          int theYears;
          String loanType;
          String theName;
          Loan theLoan;
          Customer theCust = new Customer();
          NumberFormat nf = NumberFormat.getCurrencyInstance();
          theName = Console.readString("Customer Name : ");
          theCust.setName(theName);
          loanType = Console.readString("Loan Type (V/I): ");
          thePrincipal = Console.readDouble
          ("Loan amount (no commas) :");
          theRate = Console.readDouble
          ("Interest rate in % (ex: use 7.5 for 7.5%) :")/100;
          theYears = Console.readInt ("The number of theYears:");
          if (loanType.equals("V")) {
          theLoan = new VariableLoan(thePrincipal, theRate, theYears, theCust);
          theLoan.setPrincipal(thePrincipal);
               theLoan.setRate(theRate);
          theLoan.setYears(theYears);
          else {
          theLoan = new InterestLoan(thePrincipal, theRate, theYears, theCust);
          theLoan.setPrincipal(thePrincipal);
               theLoan.setRate(theRate);
          theLoan.setYears(theYears);
          System.out.println("Customer = "+ theCust.getName());
          System.out.println("Monthly payment = "+ nf.format(theLoan.monthlyPayment()));
          System.out.println("Total Payment = "+ nf.format(theLoan.totalPayment()));
          System.out.println("Total Interest = "+ nf.format(theLoan.totalInterest()));

Similar Messages

  • When i try to use max() & pow() in jdbc i get error "cannot resolve symbol"

    hi,
    when i tried to use pow() & max() in my jdbc programme i got compilation error "cannot resolve symbol".
    even i have imorted java.math
    this is the sample.
    pr1= (fy/(L*B*pow(10.0,-6.0))+((6*mx)/(L*B*B*pow(10.0,-6.0)))+((6*mz)/(B*L*L*pow(10.0,-6.0))));
    all of above are double.
    and with max();
    pr=max(pr1,pr2);
    all of above are double.
    please help.
    thanks in advance.
    satish

    hi
    Hartmut
    thanks hartmut;
    i am new in java so i have some problems, but thanks for helping me.
    please help me again.
    as i have already posted another probleme which i have with selecting 1000 rows 1 by 1 from a table & manipulate 1 by 1 on that and then store all manipulated row to another table.
    when i tried to do so i am able to select only 600 rows and manipulate them & store them.
    i did not get any exception or any error.
    can this possible that microsoft access driver has not that much capacity to provide 1000 rows or it is problem with jdbc.
    please help.
    satish
    thanks again.

  • Cannot resolve symbol: HashMap, put and strings

    Hi,
    why woudl I get a "cannot resolve symbol" at the line indicated by <============
    sec_cands[i] should be a String already.
    Can someone help me ?
    Thanks in advance.
    HashMap temp = new HashMap();
    String [] sec_cands = sec_ex.getTargetPhrases();
    int sec_length = sec_cands.length;
    String [] allCands = new String[total_length];
    if (sec_length > 0 ) {
    for (int i = 0; i < sec_cands.length; i++)
    allCands[fr_length+i] = sec_cands;
    temp.put(sec_cands[i], true); <=================

    Sorry, I accidentally deleted a subscript from a line. The real code is "
    HashMap temp = new HashMap();
    String [] sec_cands = sec_ex.getTargetPhrases();
    int sec_length = sec_cands.length;
    String [] allCands = new String[total_length];
    if (sec_length > 0 ) {
    for (int i = 0; i < sec_cands.length; i++)
    allCands[fr_length+i] = sec_cands;
    temp.put(sec_cands[i], true); <=================

  • Try/catch and 'cannot resolve symbol'

    I am relatively new to java programming and something has me puzzled...
    Why do I get a 'cannot resolve symbol' message when I include a variable definition in a try/catch section. When I put it/them before the 'try' statement it compiles as expected. How are statements inside a try compiled differently than those outside?
    try {
        StringBuffer pageBuffer = new StringBuffer();
        String inputLine;
        BufferedReader in = new BufferedReader(
           new InputStreamReader( theURL.openStream() ) );
        while ((inputLine = in.readLine()) != null) {
             System.out.println(inputLine);
            pageBuffer.append(inputLine);
        in.close();
    } catch (Exception ignored) {}C:\Projects\WebExplorer\PageVisitor.java:142: cannot resolve symbol
    symbol : variable pageBuffer
    location: class PageVisitor
         return pageBuffer.toString();
    Paul

    A try block is just like any other block delimited by {...} in that all variables declared inside it are local to that block. I.e. they are not visible or usable anywhere outside it. Your pageBuffer variable, for example, is a local variable that can only be used inside the try-block in which it is declared.
    Your obvious solution, knowing that, is to declare the variables outside the try and catch blocks. Remember to initialize them (even to null), otherwise the compiler will complain about variables that may not have been initialized.

  • Getting cannot resolve symbol

    Please if you can help tell me what i have done wrong and how to fix it because i am
    getting a cannot resolve symbol error.
    public class loop
    public static void main(String[] args)
         System.out.println("What would you like to cut?");
         System.out.println("Oak logs");
         System.out.println("Yew logs");
         double r;
         String b = new String();
         String k = "You cut a";
         String j = new String();
         array argv;
              if (argv[0].equals("oak logs")) {
                   b = ("Oak Log");
              else {
                   b = ("Yew Log");
              do
              r = Math.random();
              while(r < 0.99999999);
              j = k + (" ") + b;
              System.out.println(j);
    }

    There is no key word or class "array", so it is giving that error.
    If you want to define an array
    do like this
    int[] intArray = {0,1,2}; // this is integer array with 0,1,2 as elements
    String[] strArray = new String[10]; // this is String array with 10 size
    for more details see this link
    www.roseindia.net/java/beginners/arrayexamples/index.shtml

  • Missing method body and cannot resolve symbol

    I keep getting these two errors when trying to compile. I know that I need to call my fibonacci and factorial functions from the main function. Is this why I am getting the missing method body error? How do I correct this?
    Am I getting the cannot resolve symbol because I have to set the num and fact to equal something?
    Thanks
    public class Firstassignment
    public static void main(String[]args)
         System.out.println();
    public static void fibonacci(String[]args);
         int even=1;
         int odd=1;
         while (odd<=100);
         System.out.println(even);
         int temp = even;
         even = odd;
         odd = odd + temp;
    public static void factorial (String[]args);
         for (int count=1;
         count<=num;
         count++);
         fact = fact * count;
         outputbox.printLine("Factorial of" + num + "is" + fact);

    Hey... :o)
    the problem is that you've put semicolons at the end of the function signature, like this:
    public static void fibonacci(String[]args);
    }that should happen only when the function is abstract... so ur function should actually look like this:
    public static void fibonacci(String[]args)
    }also, i think you've missed out on the declarations (like what are fact and num??)....

  • "cannot resolve symbol" when compiling a class that calls methods

    I am currently taking a Intro to Java class. This problem has my instructor baffled. If I have two classes saved in separate files, for example:
    one class might contain the constructor with get and set statements,
    the other class contains the main() method and calls the constructor.
    The first file compiles clean. When I compile the second file, I get the "cannot resolve symbol error" referring to the first class.
    If I copy both files to floppy and take them to school. I can compile and run them with no problem.
    If I copy the constructor file to the second file and delete the "public" from the class declaration of the constructor, it will compile and run at home.
    At home, I am running Windows ME. At school, Windows 2000 Professional.
    The textbook that we are using came with a CD from which I downloaded the SDK and Runtime Environment. I have tried uninstalling and reinstalling. I have also tried downloading directly from the Sun website and still the error persists.
    I came across a new twist tonight. I copied class files from the CD to my hard drive. 4 separate files. 3 of which are called by the 4th.
    I can run these with no problem.
    Any ideas, why I would have compile errors????
    Thanks!!

    Oooops ... violated....
    Well first a constructor should have the same name as the class name so in our case what we have actually created is a static method statementOfPhilosophy() in class SetUpSite and not a constructor.
    Now why does second class report unresolved symbol ???
    Look at this line
    Class XYZ=new XYZ();
    sounds familiar, well this is what is missing from your second class, since there is no object how can it call a method ...
    why the precompiled classes run is cuz they contain the right code perhaps so my suggestion to you is,
    1) Review the meaning and implementation of Constructors
    2) Ask your instructor to do the same ( no pun intended ... )
    3) Check out this for understanding PATH & CLASSPATH http://www.geocities.com/gaurav007_2000/java/
    4) Look at the "import" statement, when we have code in different files and we need to incorporate some code in another it is always a good idea to use import statement, that solves quite a few errors.
    5) Finally forgive any goof up on this reply, I have looked at source code after 12 months of hibernation post dot com doom ... so m a bit rusty... shall get better soon though :)
    warm regards and good wishes,
    Gaurav
    CW :-> Mother of all computer languages.
    I HAM ( Radio-Active )
    * OS has no significance in this error
    ** uninstalling and reinstalling ? r u nuttttttts ??? don't ever do that again unless your compiler fails to start, as long as it is giving a valid error it is working man ... all we need to do is to interpret the error and try to fix the code not the machine or compiler.

  • Visual Studio 2012 cannot resolve symbol or Errors control is not a member of class

    Visual Studio 2012 Web Site Project (Note not a Web application, so there are not Designer.vb files) > Site works perfectly fine and using IIS and attaching to IIS to debug code.
    However, if I try to build the site inside of Visual Studio I am getting lots of Errors ‘pnlName’ is not a member of ‘Page_Name’ In the code behind I am getting errors ‘Cannot resolve symbol ‘pnlName’
    .ascx Page
    <li style="margin-right:0;" id="pnlName" runat="server"><a href="/cart" title="Checkout" class="global-checkout">Checkout</a></li>
    .ascx.vb page
    Me.pnlName.Attributes.Remove("style")
    I have cleaned, rebuild and nothing gets rid of these errors, but again the site works as designed, but I would like to launch and debug inside of Visual Studio.
    Moojjoo MCP, MCTS
    MCP Virtual Business Card
    http://moojjoo.blogspot.com

    Cor,
    What I am stating is this is a solution using the Web Site Project instead of a
    Web Application Project.
    Web Site projects do not require Designer.vb files, Web Application Projects add Designer.vb files in the solution.   
    Background: I have been hired to support a very successful e-commerce site that was built by a 3rd party vendor (I had no input on the contract or specification, because I would have went with
    MVC).  The site works 100% correctly, however from my 2003 - 2015 experience with Visual Studio and Web Development being in Web Forms and MVC I have always built ASP.NET Solutions using the Web Application Project Templates, which compiles the code down
    to .dlls.  
    A Web Site project does not compile the code, but simply uses the .vb files and they have to be migrated to the server with the .aspx files. http://msdn.microsoft.com/en-us/library/dd547590%28v=vs.110%29.aspx
    Currently the only way I can debug this Solution is to attach to the w3wp.exe process running locally on my work station. 
    The Solution is comprised of two Web Sites, which I cannot get it to compile because of the following errors -
     'webServerControlName' is not a member of '(Protected Code Behind Class Name)'  I am reaching out to the MSDN community to see if anyone has experienced this issue with
    Web Site Projects.
    I hope that clears up the Project Type question.
    Moojjoo MCP, MCTS
    MCP Virtual Business Card
    http://moojjoo.blogspot.com

  • Cannot resolve symbol error even with class imported

    Hi
    I'm trying to print out a java.version system property but keep getting a
    cannot resolve symbol error
    symbol: class getProperty
    location: class java.lang.System
    I've looked at the API and getProperty() is a method of lang.System
    Can anyone throw any light?
    thanks
    import java.lang.System;
    class PropertiesTest {
        public static void main(String[] args) {
                String v = new System.getProperty("java.version");
                 System.out.println(v);
    }

    Thanks Jos
    It compiles but I now get a runtime error
    Exception in thread "main"
    java.lang.NoClassDefFoundError:PropertiesTest
    What do you reckon is the problem?
    thanks
    java -cp .;<any other directories or jars>
    YourClassNameYou get a NoClassDefFoundError message because the
    JVM (Java Virtual Machine) can't find your class. The
    way to remedy this is to ensure that your class is
    included in the classpath. The example assumes that
    you are in the same directory as the class you're
    trying to run.I know it's a bad habit but I've put this file (PropertiesTest.java) and the compiled class (PropertiesTest.class) both in my bin folder which contains the javac compiler

  • Having Problem with using JUnit...causes "cannot resolve symbol" problems..

    Hello, say i have a class
    A
    that contains an object of class B.
    Now there's class X...
    It's all fine and dandy trying to compile them both until i try to set the classpath for junit, by doing:
    set classpath=%classpath%;C:\junit3.8.1\junit.jar
    i'm pretty sure it's correct...
    well once i type in this line into my command prompt (win 2k), the junit package now seems to be recognized by class X, which is my testing class that contains an object of class A.
    but NOW class A can't find class B and i get a cannot resolve symbol error. Same goes for class X not being able to find class A.
    Anyone have any suggestions? I'm a newb to this :( . Thanks.

    nevermind! noob mistake.

  • Cannot find package error and cannot resolve symbol error

    Hi
    I have a file Assignment.java in C:\TIJCode\c03 folder. But this file belongs to the default package. This file imports a package com.bruceeckel.simpletest which is in C:\TIJCode\ folder. Now this package has a file named Test.java which accesses a few more files fromt he same package.
    I set the classpath to C:\TIJCode. When i try to run the Assignment file I get an error saying package com.bruceeckel.simpletest cannot be found and cannot resolve symbol error. symbol: Test Class: Assignment.
    The files in com.bruceeckel.simpletest package were not compiled. So I first tried to do that. But I get a cannot resolve symbol error while trying to compile a file NumOfLinesException which inherits SImpleTestException file. The exact error message is
    NumOfLinesException.java : 7 : cannot resolve symbol
    symbol : class SimpleTestException
    location : class com.bruceeckel.simpletest.NumOfLinesException extends SimpleTestException
    The exact code in each of above mentioned files is
    //: c03:Assignment.java
    // Assignment with objects is a bit tricky.
    // From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
    // www.BruceEckel.com. See copyright notice in CopyRight.txt.
    import com.bruceeckel.simpletest.*;
    class Number {
    int i;
    public class Assignment {
    static Test monitor = new Test();
    public static void main(String[] args) {
    Number n1 = new Number();
    Number n2 = new Number();
    n1.i = 9;
    n2.i = 47;
    System.out.println("1: n1.i: " + n1.i +
    ", n2.i: " + n2.i);
    n1 = n2;
    System.out.println("2: n1.i: " + n1.i +
    ", n2.i: " + n2.i);
    n1.i = 27;
    System.out.println("3: n1.i: " + n1.i +
    ", n2.i: " + n2.i);
    monitor.expect(new String[] {
    "1: n1.i: 9, n2.i: 47",
    "2: n1.i: 47, n2.i: 47",
    "3: n1.i: 27, n2.i: 27"
    } ///:~
    //: com:bruceeckel:simpletest:SimpleTestException.java
    // From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
    // www.BruceEckel.com. See copyright notice in CopyRight.txt.
    package com.bruceeckel.simpletest;
    public class SimpleTestException extends RuntimeException {
    public SimpleTestException(String msg) {
    super(msg);
    } ///:~
    //: com:bruceeckel:simpletest:NumOfLinesException.java
    // From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
    // www.BruceEckel.com. See copyright notice in CopyRight.txt.
    package com.bruceeckel.simpletest;
    public class NumOfLinesException extends SimpleTestException {
    public NumOfLinesException(int exp, int out) {
    super("Number of lines of output and "
    + "expected output did not match.\n" +
    "expected: <" + exp + ">\n" +
    "output: <" + out + "> lines)");
    } ///:~
    //: com:bruceeckel:simpletest:Test.java
    // Simple utility for testing program output. Intercepts
    // System.out to print both to the console and a buffer.
    // From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
    // www.BruceEckel.com. See copyright notice in CopyRight.txt.
    package com.bruceeckel.simpletest;
    import java.io.*;
    import java.util.*;
    import java.util.regex.*;
    public class Test {
    // Bit-shifted so they can be added together:
    public static final int
    EXACT = 1 << 0, // Lines must match exactly
    AT_LEAST = 1 << 1, // Must be at least these lines
    IGNORE_ORDER = 1 << 2, // Ignore line order
    WAIT = 1 << 3; // Delay until all lines are output
    private String className;
    private TestStream testStream;
    public Test() {
    // Discover the name of the class this
    // object was created within:
    className =
    new Throwable().getStackTrace()[1].getClassName();
    testStream = new TestStream(className);
    public static List fileToList(String fname) {
    ArrayList list = new ArrayList();
    try {
    BufferedReader in =
    new BufferedReader(new FileReader(fname));
    try {
    String line;
    while((line = in.readLine()) != null) {
    if(fname.endsWith(".txt"))
    list.add(line);
    else
    list.add(new TestExpression(line));
    } finally {
    in.close();
    } catch (IOException e) {
    throw new RuntimeException(e);
    return list;
    public static List arrayToList(Object[] array) {
    List l = new ArrayList();
    for(int i = 0; i < array.length; i++) {
    if(array[i] instanceof TestExpression) {
    TestExpression re = (TestExpression)array;
    for(int j = 0; j < re.getNumber(); j++)
    l.add(re);
    } else {
    l.add(new TestExpression(array[i].toString()));
    return l;
    public void expect(Object[] exp, int flags) {
    if((flags & WAIT) != 0)
    while(testStream.numOfLines < exp.length) {
    try {
    Thread.sleep(1000);
    } catch (InterruptedException e) {
    throw new RuntimeException(e);
    List output = fileToList(className + "Output.txt");
    if((flags & IGNORE_ORDER) == IGNORE_ORDER)
    OutputVerifier.verifyIgnoreOrder(output, exp);
    else if((flags & AT_LEAST) == AT_LEAST)
    OutputVerifier.verifyAtLeast(output,
    arrayToList(exp));
    else
    OutputVerifier.verify(output, arrayToList(exp));
    // Clean up the output file - see c06:Detergent.java
    testStream.openOutputFile();
    public void expect(Object[] expected) {
    expect(expected, EXACT);
    public void expect(Object[] expectFirst,
    String fname, int flags) {
    List expected = fileToList(fname);
    for(int i = 0; i < expectFirst.length; i++)
    expected.add(i, expectFirst[i]);
    expect(expected.toArray(), flags);
    public void expect(Object[] expectFirst, String fname) {
    expect(expectFirst, fname, EXACT);
    public void expect(String fname) {
    expect(new Object[] {}, fname, EXACT);
    } ///:~

    What do you have in the C:\TIJCode\ directory? Does the directory structure mimic the package structure for the stuff you're importing?

  • Cannot resolve symbol..Swing / MDI

    I'm somewhat new to Java.
    I have an MDI app that I am creating. The main routine is in DeskTop.java.
    When DeskTop.class is run:
    1)Main creates a generic UserID class from userID.java( has two private strings and 4 methods to get userid, passwd, and set userid, passwd).
    This info will be used throughout the app to connect to various MySQL Dbs.
    2)Main creates the main application JFrame and a JMenu.
    One of the JMenuItems, named Logon creates a JInternalFrame (basically a login box with userid and password field and JButton called continue. An ActionPerformed is added to a continue JButton.
    There are many other JInternalFrames on the menu that have various DB functions.
    I need to have the action performed on the ActionEvent of the continue button access the UserID class and it's setUserID() and setPasswd() methods and set the (uid, pw) fields in the object. Yet anytime I try to access this object from the Logon object, I get a Cannot resolve symbol:
    This is a summary of the action performed on the continue button:
    uid = txt_userID.getText();
    userid = new String(uid).trim();
    pw = pw_password.getPassword();
    password = new String(pw).trim();
    UserID.setUserID(userid); /*UserID is the other object.Error is on*/
    UserID.setPasswd(password); /*the decimal point.*/
    All objects have a public constructor and the methods I am trying access are declared public.
    Files consist of (all in same directory):
    DeskTop.java (main JFRAME)
    PasswordBox.java ( JInternalFrame)
    UserIDPW.java (JInternalFrame)
    AddCompany.java (JInternalFrame)
    etc. ( other JInternalFrames)
    etc. ( other classes)
    Thanks for any input. If someone has a better method of making a MDI database app in Java, some info would be great.
    There will be other classes outside the gui. I am trying to build the business logic and the gui as seperate as I can.

    This may sound silly to ask, but without seeing all
    the code in this case you can imagine it's difficult
    to say - I presume that UserID is a class (ie a
    template for an object) rather than an object itself
    and that setUserID, setPasswd are static functions.
    The files you list dont include a UserID.java, so this
    means you haven't got a PUBLIC class called UserID
    (you may have one with private or package / friendly
    access) - hence you can't access it from outside. I am
    new myself - but this looks a likely candidate. [ I
    try to answer questions so that I can learn myself,
    but now I am off to bed!]Thank for the reply.
    The main function creates a public UserID object and it created the main gui JFrame DeskTop object. UserID has a public constructor and public methods.
    main function:
    public static void main(String args[]) {
    userIDPW userID = new userIDPassword();
    JFrame f = new DeskTop();
    Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
    f.setSize(screensize);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
    The DeskTop object has a JMenuitem in it called Login, it opens an InternalJFrame called PasswordBox.
    PasswordBox takes a userid and pw and then it needs to send the userid and pw to the userID object with two of its methods:
    Methods in userID object:
    public void setUserID(String userid)
    { this.userid = userid; }
    public void setPasswd(String passwd)
    ( this.passwd = passwd; }
    How doed one access this object (userID)? I have tried (from the PasswordBox) with no success:
    uid = txt_userID.getText();
    userid = new String(uid).trim();
    pw = pw_password.getPassword();
    password = new String(pw).trim();
    userID.setUserID(userid); --this fails, with Cannot resolve symbol
    userID.setPasswd(password); --this fails, with Cannot resolve symbol

  • Cannot resolve symbol - DiveLog

    I feel my self a little bit stupid, but I will ask.
    When I try DiveLog.java sample in "New to Java" section,
    I am getting ".. cannot resolve symbol" for Welcome and
    other classes. I have this files in divelog
    directory and compiled by javac. What should I check else.
    Thank you very much in advance.
    natakan

    Yes I studied a few tutorial and run some
    simple codes. I looked also package. But
    I am missing something here.
    And I have enough experience in
    OO technology. this is way I am feeling
    myself stupid.
    Any way thank you very much
    natakan
    You should do some other tutorial first. DiveLog is
    too advanced for you at this point.
    Try starting from
    http://java.sun.com/docs/books/tutorial/java/index.html
    Feel free to skip parts you already know but pay
    attention when it discusses "packages".

  • Can't figure out why an object isn't visible - CANNOT RESOLVE SYMBOL

    I have a simple 3 class app, all in the same package. Classes are:
    - BjackServlet, BjackDAO, and Player
    I get the compile error (I'm using Ant):
    [javac] C:\Tomcat4118\src\webapps\hellobjack\src\mybjpack\BjackServlet.java
    59: cannot resolve symbol
    [javac] symbol : variable thePlayer
    [javac] location: class mybjpack.BjackServlet
    [javac] String gp = thePlayer.getPassword();
    The pertinent code from the 3 classes is below. The offending code is in bold. Why can't I see the object from the BjackServlet.doGet() method? I can see it from within BjackDAO.addPlayer() after the "thePlayer" object has been instantiated. Please help...thanks in advance!
    package mybjpack;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.lang.*;
    public class BjackServlet extends HttpServlet {
         private BjackDAO theBlackjackDAO;
         public void init() throws ServletException {
              String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
              String dbUrl = "jdbc:microsoft:sqlserver://localhost:1433";
              String dbuserid = "testlogin";
              String dbpass = "1climb1";
              String dbname = "ejh_blackjack1";
              String connectstring = "jdbc:microsoft:sqlserver://localhost:1433;User=testlogin;Password=1climb1;DatabaseName=ejh_blackjack1";
         try {
           theBlackjackDAO = new BjackDAO(driver, dbUrl, dbuserid, dbpass, dbname, connectstring);
         catch (IOException exc) {
              System.err.println(exc.toString());
         catch (ClassNotFoundException cnf) {
              System.err.println(cnf.toString());
         catch (SQLException seq) {
              System.err.println(seq.toString());
      public void doPost(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
        doGet(request, response);
      public void doGet(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
         String command = request.getParameter("command");
         if (command == null || (command.equals("stats"))) { //player wants to go to stats page
         else if (command.equals("Add")) { //a new player adds himself to the game site
              try {
              theBlackjackDAO.addPlayer(request, response);
              String gp = thePlayer.getPassword();
              System.out.println("the Player.getPassword method yields: " + gp);
              catch (Exception exc) {
                   System.err.println(exc.toString());
         else if (command.equals("enter")) { //an experienced player enters via index.html
         else if (command.equals("play")) {
    etc...
    package mybjpack;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.lang.*;
    public class BjackDAO {
         private Connection myConn;
         public Player thePlayer;
         public BjackDAO(String driver, String dbUrl, String dbuserid, String dbpass, String dbname, String connectstring)
                   throws IOException, ClassNotFoundException, SQLException {
              System.out.println("Loading driver: " + driver);
              Class.forName(driver);
              System.out.println("Connection to: " + dbUrl);
              myConn = DriverManager.getConnection(connectstring);
              System.out.println("Connection successful! Database is " + dbname);
         public void addPlayer(HttpServletRequest request, HttpServletResponse response)
                   throws IOException, SQLException, NumberFormatException {
              //* read all the form values ...
              String ppass = request.getParameter("formpass");
              String puser = request.getParameter("formuser");
              int ppile = Integer.parseInt(request.getParameter("pile"));
              int pstatus = 1;
              int pbet = Integer.parseInt(request.getParameter("bet"));
              int paccount = Integer.parseInt(request.getParameter("account"));
              //* and write them to player object instance variables
              System.out.println("Player instantiation beginning...");
              Player thePlayer = new Player(pstatus, ppile, pbet, puser, paccount, ppass);
              String insertSql =
                   "INSERT INTO tbl_player (user_id, psswrd, account, default_pile, default_bet) "
                   + "VALUES ('" + puser + "', '" + ppass + "', '" + paccount + "', "
                   + "'" + ppile + "', '" + pbet + "')";
                   Statement myStmt = myConn.createStatement();
                   myStmt.execute(insertSql);
                   myStmt.close();
              return;
    package mybjpack;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.lang.*;
    public class Player implements java.io.Serializable {
         private String ouser;
         public String opass;
         private int opile;
         private int oaccount;
         private int obet;
         private int ostatus;
         public Player(int theStatus, int thePile, int theBet,
                             String theUser, int theAccount, String thePass) {
              ouser = theUser;
              opass = thePass;
              opile = thePile;
              oaccount = theAccount;
              obet = theBet;
              ostatus = theStatus;
         public String getUser(){
              return ouser;
         public void setUser(String vuser){
              String ouser = vuser;
         public String getPassword(){
              return opass;
         public void setPassword(String vpass){
              String opass = vpass;
         public int getPile(){
              return opile;
         public void setPile(int vpile){
              int opile = vpile;
         public int getBet(){
              return obet;
         public void setBet(int vbet){
              int obet = vbet;
         public int getAccount(){
              return oaccount;
         public void setAccount(int vaccount){
              int oaccount = vaccount;
         public int getStatus(){
              return ostatus;
         public void setStatus(int vstatus){
              int ostatus = vstatus;

    First glance, try this
    String gp = theBlackjackDAO.thePlayer.getPassword();

  • Getting error message Cannot Resolve Symbol when trying to compile a class

    Hello All -
    I am getting an error message cannot resolve symbol while trying to compile a java class that calls another java class in the same package. The called class compiles fine, but the calling class generates
    the following error message:
    D:\Apache Tomcat 4.0\webapps\examples\WEB-INF\classes\cal>javac
    ConnectionPool.java
    ConnectionPool.java:158: cannot resolve symbol
    symbol : class PooledConnection
    location: class cal.ConnectionPool
    private void addConnection(PooledConnection value) {
    ^
    ConnectionPool.java:144: cannot resolve symbol
    symbol : class PooledConnection
    location: class cal.ConnectionPool
    PooledConnection pcon = new PooledConnection(con);
    ^
    ConnectionPool.java:144: cannot resolve symbol
    symbol : class PooledConnection
    location: class cal.ConnectionPool
    PooledConnection pcon = new PooledConnection(con);
    The code is listed as follows for PooledConnection.java (it compiles fine)
    package cal;
    import java.sql.*;
    public class PooledConnection {
    // Real JDBC Connection
    private Connection connection = null;
    // boolean flag used to determine if connection is in use
    private boolean inuse = false;
    // Constructor that takes the passed in JDBC Connection
    // and stores it in the connection attribute.
    public PooledConnection(Connection value) {
    if ( value != null ) {
    connection = value;
    // Returns a reference to the JDBC Connection
    public Connection getConnection() {
    // get the JDBC Connection
    return connection;
    // Set the status of the PooledConnection.
    public void setInUse(boolean value) {
    inuse = value;
    // Returns the current status of the PooledConnection.
    public boolean inUse() {
    return inuse;
    // Close the real JDBC Connection
    public void close() {
    try {
    connection.close();
    catch (SQLException sqle) {
    System.err.println(sqle.getMessage());
    Now the code for ConnectionPool.java class that gives the cannot
    resolve symbol error
    package cal;
    import java.sql.*;
    import java.util.*;
    public class ConnectionPool {
    // JDBC Driver Name
    private String driver = null;
    // URL of database
    private String url = null;
    // Initial number of connections.
    private int size = 0;
    // Username
    private String username = new String("");
    // Password
    private String password = new String("");
    // Vector of JDBC Connections
    private Vector pool = null;
    public ConnectionPool() {
    // Set the value of the JDBC Driver
    public void setDriver(String value) {
    if ( value != null ) {
    driver = value;
    // Get the value of the JDBC Driver
    public String getDriver() {
    return driver;
    // Set the URL Pointing to the Datasource
    public void setURL(String value ) {
    if ( value != null ) {
    url = value;
    // Get the URL Pointing to the Datasource
    public String getURL() {
    return url;
    // Set the initial number of connections
    public void setSize(int value) {
    if ( value > 1 ) {
    size = value;
    // Get the initial number of connections
    public int getSize() {
    return size;
    // Set the username
    public void setUsername(String value) {
    if ( value != null ) {
    username = value;
    // Get the username
    public String getUserName() {
    return username;
    // Set the password
    public void setPassword(String value) {
    if ( value != null ) {
    password = value;
    // Get the password
    public String getPassword() {
    return password;
    // Creates and returns a connection
    private Connection createConnection() throws Exception {
    Connection con = null;
    // Create a Connection
    con = DriverManager.getConnection(url,
    username, password);
    return con;
    // Initialize the pool
    public synchronized void initializePool() throws Exception {
    // Check our initial values
    if ( driver == null ) {
    throw new Exception("No Driver Name Specified!");
    if ( url == null ) {
    throw new Exception("No URL Specified!");
    if ( size < 1 ) {
    throw new Exception("Pool size is less than 1!");
    // Create the Connections
    try {
    // Load the Driver class file
    Class.forName(driver);
    // Create Connections based on the size member
    for ( int x = 0; x < size; x++ ) {
    Connection con = createConnection();
    if ( con != null ) {
    // Create a PooledConnection to encapsulate the
    // real JDBC Connection
    PooledConnection pcon = new PooledConnection(con);
    // Add the Connection to the pool.
    addConnection(pcon);
    catch (Exception e) {
    System.err.println(e.getMessage());
    throw new Exception(e.getMessage());
    // Adds the PooledConnection to the pool
    private void addConnection(PooledConnection value) {
    // If the pool is null, create a new vector
    // with the initial size of "size"
    if ( pool == null ) {
    pool = new Vector(size);
    // Add the PooledConnection Object to the vector
    pool.addElement(value);
    public synchronized void releaseConnection(Connection con) {
    // find the PooledConnection Object
    for ( int x = 0; x < pool.size(); x++ ) {
    PooledConnection pcon =
    (PooledConnection)pool.elementAt(x);
    // Check for correct Connection
    if ( pcon.getConnection() == con ) {
    System.err.println("Releasing Connection " + x);
    // Set its inuse attribute to false, which
    // releases it for use
    pcon.setInUse(false);
    break;
    // Find an available connection
    public synchronized Connection getConnection()
    throws Exception {
    PooledConnection pcon = null;
    // find a connection not in use
    for ( int x = 0; x < pool.size(); x++ ) {
    pcon = (PooledConnection)pool.elementAt(x);
    // Check to see if the Connection is in use
    if ( pcon.inUse() == false ) {
    // Mark it as in use
    pcon.setInUse(true);
    // return the JDBC Connection stored in the
    // PooledConnection object
    return pcon.getConnection();
    // Could not find a free connection,
    // create and add a new one
    try {
    // Create a new JDBC Connection
    Connection con = createConnection();
    // Create a new PooledConnection, passing it the JDBC
    // Connection
    pcon = new PooledConnection(con);
    // Mark the connection as in use
    pcon.setInUse(true);
    // Add the new PooledConnection object to the pool
    pool.addElement(pcon);
    catch (Exception e) {
    System.err.println(e.getMessage());
    throw new Exception(e.getMessage());
    // return the new Connection
    return pcon.getConnection();
    // When shutting down the pool, you need to first empty it.
    public synchronized void emptyPool() {
    // Iterate over the entire pool closing the
    // JDBC Connections.
    for ( int x = 0; x < pool.size(); x++ ) {
    System.err.println("Closing JDBC Connection " + x);
    PooledConnection pcon =
    (PooledConnection)pool.elementAt(x);
    // If the PooledConnection is not in use, close it
    if ( pcon.inUse() == false ) {
    pcon.close();
    else {
    // If it is still in use, sleep for 30 seconds and
    // force close.
    try {
    java.lang.Thread.sleep(30000);
    pcon.close();
    catch (InterruptedException ie) {
    System.err.println(ie.getMessage());
    I am using Sun JDK Version 1.3.0_02" and Apache/Tomcat 4.0. Both the calling and the called class are in the same directory.
    Any help would be greatly appreciated.
    tnx..
    addi

    Is ConnectionPool in this "cal" package as well as PooledConnection? From the directory you are compiling from it appears that it is. If it is, then you are compiling it incorrectly. To compile ConnectionPool (and PooledConnection similarly), you must change the current directory to the one that contains cal and type
    javac cal/ConnectionPool.

Maybe you are looking for

  • NiRFSG_CheckGenerationStatus fails periodically

    Hello: I keep observing this strange effect once in a while with my 3 channel PXI-5673 system. Just to make it clear - I have yet to find a way to reproduce this problem. NI-RFSG 1.6.3. There are three generators, daisy chained. I set them to generat

  • IPod touch (4th gen) won't connect to my wifi after being lost

    I lost my iPod touch (4th gen) yesterday so "locked" it using iCloud. The nice folks at the vet office found it and I retrieved it today. Noticed it wasn't actually locked, could listen to podcasts and open apps right away, and it syncs fine when I c

  • How can I increment the index of an array in a formula node?

    Hi, I need some help with the formula node. I need an array, that increment every iteration of the code in the formula node. I need it to save amplitudes. I thought i could do this with i++; i is the variable for my index. Martin Solved! Go to Soluti

  • Camera connection kit for i pad 3

    Hi I had a generic camera kit but it has broke while i was trying to figure it out. I am now wanting a genuine apple one. There are some on e bay model MC531ZM/A. It has the correct 30 pin connector, but they tell me it is only suitable for i pad 1 a

  • Refine Edge - Removing mask edge ?

    Hi, I teach Photoshop 5.5 and have started teaching Photoshop Touch to some of my younger students. I am having trouble with the refine edge tool which works well in CS 5.5 The scribble selection tool works well however I need to use the refine edge