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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:25:36+00:00 2026-06-09T18:25:36+00:00

I have a predefined table in a mySQL database: I am working on saving

  • 0

I have a predefined table in a mySQL database:
enter image description here

I am working on saving data inputted from the user to the database but I cant seem to any data to save in the database. With the following code I am trying to update the first row of the database (ID: 1 through OTHER 2: 0). What am I doing wrong?

private java.sql.Connection con = null;
private PreparedStatement pst = null;
private ResultSet rs = null;
private String url = "jdbc:mysql://localhost:8889/deliveryEarn";
private String user = "root";
private String password = "root";

try {
     con = DriverManager.getConnection(url, user, password);
     Statement st = (Statement) con.createStatement(); 

     st.executeUpdate("INSERT INTO incomeCalc " + "VALUES (3, 75, 6, 25, 18.50)");

     con.close();
}

catch (SQLException ex) {
     Logger lgr = Logger.getLogger(deliveryMain.class.getName());
     lgr.log(Level.SEVERE, ex.getMessage(), ex);

 } 
  • 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-09T18:25:38+00:00Added an answer on June 9, 2026 at 6:25 pm

    I think it will not work because the number of values is less than the number of columns in your table. What you have to do is to specify the name of columns to match the number of your values.

    INSERT INTO incomeCalc VALUES (3, 75, 6, 25, 18.50)  // error
    // the only way this will work is when you have only 5 columns in 
    // your table but in your case you have 7 that is why it will not work
    

    it should be

    INSERT INTO incomeCalc(specify columns here to the values bound to)
    VALUES (3, 75, 6, 25, 18.50)
    

    w3School: (INSERT)

    It is possible to write the INSERT INTO statement in two forms.

    The first form doesn’t specify the column names where the data will be inserted, only their values:

    INSERT INTO table_name
    VALUES (value1, value2, value3,...)
    

    The second form specifies both the column names and the values to be inserted:

    INSERT INTO table_name (column1, column2, column3,...)
    VALUES (value1, value2, value3,...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have some code that archives data from a Microsoft Access database into a
Seem's to be a stupid problem but here I go... I have a table
I have a SMTP server that only accepts a predefined From sender. However, I
I have the following assignment: Implement a basic shopping basket without using any predefined
i have some troubles filling a predefined table with a stored procedure. mytable has
I have a table (actually a view, but simplified my example to a table)
i have an existing mysql table with the id column defined as primary, and
I want to make a database user, which would use my predefined functions (login(pass,
In my mySQL database under products table, there are a lot of shops selling
In one of my Sitecore solutions the user needs to have some predefined CSS

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.