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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:53:30+00:00 2026-06-05T06:53:30+00:00

After validation of select combo box which I have selected and I am not

  • 0

After validation of select combo box which I have selected and I am not able to insert it in my database. Tomcat gives following error:

java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).

How is this caused and how can I solve it?

  • 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-05T06:53:31+00:00Added an answer on June 5, 2026 at 6:53 am

    You will get this error when you call any of the setXxx() methods on PreparedStatement, while the SQL query string does not have any placeholders ? for this.

    For example this is wrong:

    String sql = "INSERT INTO tablename (col1, col2, col3) VALUES (val1, val2, val3)";
    // ...
    
    preparedStatement = connection.prepareStatement(sql);
    preparedStatement.setString(1, val1); // Fail.
    preparedStatement.setString(2, val2);
    preparedStatement.setString(3, val3);
    

    You need to fix the SQL query string accordingly to specify the placeholders.

    String sql = "INSERT INTO tablename (col1, col2, col3) VALUES (?, ?, ?)";
    // ...
    
    preparedStatement = connection.prepareStatement(sql);
    preparedStatement.setString(1, val1);
    preparedStatement.setString(2, val2);
    preparedStatement.setString(3, val3);
    

    Note the parameter index starts with 1 and that you do not need to quote those placeholders like so:

    String sql = "INSERT INTO tablename (col1, col2, col3) VALUES ('?', '?', '?')";
    

    Otherwise you will still get the same exception, because the SQL parser will then interpret them as the actual string values and thus can’t find the placeholders anymore.

    See also:

    • JDBC tutorial – prepared statements
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with validation messages not showing after a redirect, even when
I currently have a form built in which after validation, if errors exist, the
I have problem with repopulating form_upload after validation. Other input fields or selectboxes are
I'm creating the following trigger: CREATE TRIGGER Trigger_UpdateTrainingDelivery AFTER DELETE OR INSERT OR UPDATE
I am using jquery validation plugin. I have an html that looks like: <h2>Select
Can a default value Select One be set to SelectOneMenu component after a validation
jQuery Validation plugin is used to validate all form data: http://docs.jquery.com/Plugins/Validation Have 3 select
I have the following code in my controller after the user posts the form
I have a signup form on my home page which uses server side validation
I have this code for login validation using a Struts2 action class which calls

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.