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 5983363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:13:10+00:00 2026-05-22T22:13:10+00:00

I researched this around and still can’t seem to solve this problem. I have

  • 0

I researched this around and still can’t seem to solve this problem. I have the following in my program:

   public void InsertDB(double price, double shares, String ticker, int id)throws Exception {
   //do some stuff
   }

I tried the following within my main class(and got the above error non-static method cannot be referenced in static context):

InsertDB(constants[i], variables[i], ticker[i], count);

Then I read you must create a new instance so I tried(Testingground is the name of my program) and I get an error saying it cannot find the InsertDB symbol:

Testingground myObject = new InsertDB();

I’m new to java and kind of inherited this program(I haven’t had this problem with my programs), can someone tell me what I can do to get this to work and the logic behind it?(my insertdb class gives me errors if I turn it to static so that approach won’t work). I also read that it might work if I changed public to protected but it still didn’t work.

Thanks in advance

  • 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-22T22:13:11+00:00Added an answer on May 22, 2026 at 10:13 pm

    You need to instantiate the class itself, not the method InsertDB(). You instantiate a class by using the key word new. You can refer to the official tutorial on the oracle/sun docs.

    Example:

    Testingground myObject = new Testingground();
    myObject.InsertDB(constants[i], variables[i], ticker[i], count);
    

    Methods can also be declared as static. In that case you can reference them directly ie. Testingground.InsertDB(constants[i], variables[i], ticker[i], count); without constructing an object for that class.

    Also by convention method names are camel cased. Read more about naming conventions in java here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've done a lot of research on this questions but still can't seem to
I researched this question for days and cannot seem to find an option I
I have researched this for a few hours and I am kind of frustrated.
I have researched enough on this topic sans any luck :-( My requirement is
I feel like this is a common problem but nothing I've researched has worked
I have researched this for a long time and have not found an answer.
First, I have researched this question a lot. I learned how to read from
I currently have my head wrapped around this issue - its driving me crazy.
I have the following html submit form. This form is a PHP_SELF and stores
I 've researched and noticed that ActiveResource lack this functionality. So, what is the

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.