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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:58:49+00:00 2026-06-17T20:58:49+00:00

I have a form and I want to send the data to a database.

  • 0

I have a form and I want to send the data to a database. How can I pass the request data through the method parameters and send it to the Database?

int status = InsertCustomer(fName, mName, lName , iage, issn, city, state, country);

//Method
// This method should return an int that the executeUpdate       // methods returns. Note: the driver name and the URL are       // already available in the init() method.

  private int InsertCustomer(String firstName, String midName, String lastName, int age, int ssn, String city, String state, String country) {

    // JDBC logic


    try {
        Class.forName(driverName);
        Connection conn = DriverManager.getConnection(databaseURL);
        java.sql.Statement st = conn.createStatement();


        st.executeUpdate("INSERT INTO Customer(firstName, midName, lastName, age, ssn, city, state, country)" + 
                   "VALUES ('?', '?', '?', ?, ?, '?', '?', '?')";


    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }

    return 1;
}

I’m a lil bit lost, a little would be very much appreciated.

  • 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-17T20:58:50+00:00Added an answer on June 17, 2026 at 8:58 pm

    Either you use a simple (i.e. not prepared statement), and you can’t pass any parameter:

    String sql = "insert into sometable (a, b, c) values (7, 8, 9)";
    Statement st = conn.createStatement();
    return st.executeUpdate(sql);
    

    Or (and in your case, that’s what you should do), you use a prepared statament and pass parameters:

    String sql = "insert into sometable (a, b, c) values (?, ?, ?)";
    PreparedStatement st = conn.prepareStatement(sql);
    st.setInt(1, 7);
    st.setInt(2, 8);
    st.setInt(3, 9);
    return st.executeUpdate();
    

    In your code, you’re using a simple statement and try to execute a SQL query which needs parameters. That’s not possible. You need a prepared statement to do that.

    More information in the JDBC tutorial.

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

Sidebar

Related Questions

I want to send the form data to server-side. I have two ways: Normal
I have form and I want to send values from it with ajax to
I have this form. Basically what I want is to send a auto-response with
I have form and I want to grab the data inserted by users and
I have a login form i want to send username password to servlet and
I have created some form for inserting data into database and for checking if
I have a very simple form.I want to insert the form data in mysql
We have an MS Access 2007 database with a simple form displaying table data.
i have to send form data which have multiselect boxes to a servlet using
I have an ASP.Net form and I want to send an email when 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.