oracle 以下错误是什么意思:java.sql.sqlexception 在索引处缺少输入或输出参数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5706886/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
what does the following error mean: java.sql.sqlexception missing in or out parameter at index
提问by jdbcnewbie.
I get the following error when working on some JDBC code:
在处理某些 JDBC 代码时出现以下错误:
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?
有人可以解释一下这是什么意思吗?更一般地说,是否有网站/文档集可以解释错误声明的含义?
回答by Vladimir Dyuzhev
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:
现在,参数 #6 未绑定,未提供任何值。语句不知道将什么值发送到数据库(默认情况下它不会发送 NULL)。如果参数值未知,您应该执行以下操作:
st.setNull(6,Types.VARCHAR);
回答by lobster1234
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.
你能粘贴你的 PreparedStatement 代码吗?这意味着你有一个额外的?在您没有为其设置值的语句中。