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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:20:30+00:00 2026-06-13T17:20:30+00:00

I’ve got two classes: MAIN and DBCONNECT DBCONNECT has all the coding including the

  • 0

I’ve got two classes:

MAIN and DBCONNECT

DBCONNECT has all the coding including the methods that will connect to, insert and update a database/table.

MAIN is where my GUI is created and uses the DBCONNECT class.

In my DBCONNECT class I have created a method that writes the input info to a table.

String sqlInsert1 = "INSERT INTO Drivers (IDNumber, FirstName, LastName) VALUES " + Id +"," + FirstName+"," + Surname;
String sqlInsert2 = "INSERT INTO Offences(IDNumber, SpeedLimit, DriverSpeed, SeatBelt, DrunkenDriving, DriversLicense) VALUES" + Id + SpeedLimit + DriversSpeed + Seatbelt + DrunkenDriving + License;
String sqlInsert3 = "INSERT INTO DriverPoints(IDNumber, Points) VALUES" + Id + Points;

 public void writeToDB(String sqlInsert1, String sqlInsert2, String sqlInsert3)
    {
        try
        {
            Statement st = conn.createStatement();
            st.executeUpdate(sqlInsert1);
            st.executeUpdate(sqlInsert2);
            st.executeUpdate(sqlInsert3);
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(null, "Error: Could not read from database");
        }
    }

And In my MAIN class I want to use this method when the Save button is clicked

public void actionPerformed(ActionEvent ae)
{
    if (ae.equals(save))
    {
        database.writeToDB();
    }
}

It keeps giving me an error

required:java.language.String,java.language.String,java.language.String

Please let me know what I am doing wrong here.

  • 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-06-13T17:20:31+00:00Added an answer on June 13, 2026 at 5:20 pm

    you need to write like this:

    public void actionPerformed(ActionEvent ae)
    {
        if (ae.equals(save))
        {
            String sqlInsert1 = "INSERT INTO Drivers (IDNumber, FirstName, LastName) VALUES " + Id +"," + FirstName+"," + Surname;
            String sqlInsert2 = "INSERT INTO Offences(IDNumber, SpeedLimit, DriverSpeed, SeatBelt, DrunkenDriving, DriversLicense) VALUES" + Id + SpeedLimit + DriversSpeed + Seatbelt + DrunkenDriving + License;
            String sqlInsert3 = "INSERT INTO DriverPoints(IDNumber, Points) VALUES" + Id + Points;
    
            database.writeToDB(sqlInsert1,sqlInsert2,sqlInsert3);
        }
    

    It is because your method writeToDB accepts three String parameters and you are giving no arguments when you are calling it in your code.

    And the string variables that you have created before your writeToDb method are not the same as the variables declared as parameters in the writeToDB method.

    Look at this question to know the difference between arguments and parameters

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I need a function that will clean a strings' special characters. I do NOT
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into

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.