Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1047915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:22:30+00:00 2026-05-16T16:22:30+00:00

This is some very simple java OOP but I haven’t done this in a

  • 0

This is some very simple java OOP but I haven’t done this in a while…I’m getting a “symbol not found” error when referencing one java class from another

Class #1:

package toaV2;

import java.sql.Connection;

public class vehicle_model
{
    public db_model DB;
    public Connection conn;

    public static void main(String[] args) {
        vehicle_model v = new vehicle_model("system");
    }

    public vehicle_model(String sys) {      
        DB = new db_model(sys);
        conn = DB.connect();

        if(conn != null) {
            System.err.println("Got a connection.");
        }
        else {
            System.err.println("Couldn't get a connection...");         
        }
    }
}

Class #2:

package toaV2;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class db_model
{
    private static String driver = "com.mysql.jdbc.Driver";

    private static String dbUser = "user";
    private static String dbPass = "pass";
    private static String dbUrl = "jdbc:mysql://url";

    private static String system;
    public static Connection conn;

    public db_model(String sys)
    {
        system = sys;
    }

    public static Connection connect()
    {
        conn = null;
        try
        {
            String dbName = system.toUpperCase();
            String dbHost = dbUrl + dbName;

            Class.forName(driver).newInstance();
            conn = DriverManager.getConnection(dbUrl, dbUser, dbPass);
        } 
        catch(Exception e) 
        {
          System.err.println("Exception: " + e.getMessage());
        }

        return conn;
    }
}

And the errors I get on compilation:

$ javac vehicle_model.java 
vehicle_model.java:10: cannot find symbol
symbol  : class db_model
location: class toaV2.vehicle_model
    public db_model DB;
               ^
vehicle_model.java:24: cannot find symbol
symbol  : class db_model
location: class toaV2.vehicle_model
        DB = new db_model(system);
                         ^
2 errors
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:22:31+00:00Added an answer on May 16, 2026 at 4:22 pm

    You must compile your two files in the same command, like

     javac vehicle_model.java db_model.java
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this might be very easy to some,, I have a simple string
This is probably very easy to do but for some reason I can't seem
This might seem like a very easy question for some of you folks, but
This is a very common but rarely solved topic. I seriously need some help
This is almost certainly a very silly question, but for some reason I'm having
This should be a very basic design question, but for some reason it doesn't
This is a very simple question for many of you reading this, but it's
This is my first time posting -- I found similar issues but not anything
I have a very simple client server code written java(server listens on some port
Sorry, I'm new to Java and there's probably a very simple answer to this.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.