Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 451
jdbcnewbie. Avatar asked Apr 18 '11 17:04

jdbcnewbie.


1 Answers

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);
like image 155
Vladimir Dyuzhev Avatar answered Sep 27 '22 19:09

Vladimir Dyuzhev