what does the following error mean: java.sql.sqlexception missing in or out parameter at index

11,877

Solution 1

You have a statement like:

select foo from bar where a=? and b=? and c=? ...

You code binds the values to parameters:

st.setInteger(1,123); // goes to a
st.setString(2,"hello"); // goes to b
...

Now, parameter #6 is not bound, no value provided. Statement doesn't know what value to send over to DB (it will not send NULL by default). You should do something like this if parameter value is not known:

st.setNull(6,Types.VARCHAR);

Solution 2

Can you paste your PreparedStatement code? What this means is that you have have an extra ? in the statement for which you're not setting a value.

Share:
11,877

Related videos on Youtube

jdbcnewbie.
Author by

jdbcnewbie.

Updated on June 04, 2022

Comments

  • jdbcnewbie.
    jdbcnewbie. almost 2 years

    I get the following error when working on some JDBC code:

    java.sql.sqlexception missing in or out parameter at index: 6
    

    Can somebody explain what this means? More generally, is there a website/set of documentation that will explain what an error statement means?