Skip to content
Advertisement

java.sql.SQLException: Missing IN or OUT parameter at index:: 1

I made some Java 1.6-Oracle11g-JDBC (using OJDBC 6) code (below). I am getting an exception – java.sql.SQLException: Missing IN or OUT parameter at index:: 1 Why is this happening and how do I fix it ?

My output is-

JavaScript

The code is-

JavaScript

EDIT – To correct the code, we use-

//insert 1st row

JavaScript

//insert 2nd row

JavaScript

Advertisement

Answer

This is not how SQL works:

JavaScript

The values (hans,germany) should use column names (emp_name, emp_address). The values are provided by your program by using the Statement.setString(pos,value) methods. It is complaining because you said there were two parameters (the question marks) but didn’t provide values.

You should be creating a PreparedStatement and then setting parameter values as in:

JavaScript
Advertisement