File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Oracle/OAS and the fly likes java.sql.SQLException: Missing IN or OUT parameter at index:: 1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "java.sql.SQLException: Missing IN or OUT parameter at index:: 1" Watch "java.sql.SQLException: Missing IN or OUT parameter at index:: 1" New topic
Author

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

meera meera
Greenhorn

Joined: Feb 18, 2004
Posts: 1
private static final String UPDATE_USER = "update telephone set first_name=?,last_name=?,phone=? where id=?";
.
. some code
.
statement = connection.prepareStatement(UPDATE_USER);
System.out.println("trying to update user");
statement.setInt(4,id);
result = statement.executeQuery();
if(result.next()) {
statement.setString(1,user.getFirstName());
statement.setString(2,user.getLastName());
statement.setString(3,user.getPhone());
statement.setInt(4,id);
statement.execute();
System.out.println("updated");
}
.
.
.
I am getting the following error:
java.sql.SQLException: Missing IN or OUT parameter at index:: 1
i am not knowing what the error is plz help me.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Um the first part says
"statement.setInt(4,id);
result = statement.executeQuery();"
Here you are executing the query without setting the first three parameters. You cannot do that. That is why you get the error.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Chetan Lakshmeshwar
Greenhorn

Joined: Feb 04, 2003
Posts: 8
in my case i was using 3 sqls (kinda transaction) through the same reference.
even though i had used pstmt.clearParameters() it was not having any effect.
i had to specifically say pstmt=null before i started off with the 2nd sql

my code was something like this before

pstmt=con.prepareStatement(sql1);
//execute this
pstmt.execute();
pstmt=con.prepareStatement(sql2);
pstmt.clearParameters();
//execute this

afterwards I changed it to and it worked.

pstmt=con.prepareStatement(sql1);
//execute this
pstmt.execute();
pstmt=null;
pstmt=con.prepareStatement(sql2);
//execute this
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1135

Chetu,
Allow me to suggest "close()"ing the "PreparedStatement" before reusing it (and before setting it to null, of-course)!

Good Luck,
Avi.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.sql.SQLException: Missing IN or OUT parameter at index:: 1