這似乎是一個經常遇到的問題,但沒有具體的答案。我從來沒有遇到過這個問題。該代碼是在這裏:Java SQL異常在index :: 1處缺少IN或OUT參數
public static Reservation retrieveReservation()throws IOException,
SQLException{
Reservation testRsv = new Reservation();
try {
Connection con = null;
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection(
"jdbc:oracle:thin:@wewe",
"ewew",
"sdsds");
con.setAutoCommit(false);
try {
PreparedStatement prepareStatement = con.prepareStatement("SELECT *
FROM SMD_RESERVATION_INSTANCES WHERE id = ?");
ResultSet rset = prepareStatement.executeQuery();
prepareStatement.setString(1, localIDTest);
prepareStatement.executeUpdate();
prepareStatement.close();
con.commit();
if(rset.next()){
retrievedID = rset.getString("ID");
Blob blob = rset.getBlob("RESERVATIONINST");
status = rset.getString("STATUS");
long blobLength = blob.length();
int pos = 1; // position is 1-based
int len = 10;
byte[] bytes = blob.getBytes(pos, len);
InputStream is = blob.getBinaryStream();
ObjectInputStream ois = new ObjectInputStream(is);
testRsv = (Reservation)ois.readObject();
}
// System.out.println("Map Size: " + retrievedmap.size());
rset.close();
con.close();
}catch(IOException ioe){
System.err.print(ioe);
}
}catch(ClassNotFoundException cnfe){
System.err.print(cnfe);
}
return testRsv;
}
它產生如下:
java.sql.SQLException: Missing IN or OUT parameter at index:: 1
任何想法,爲什麼? 我已經重新檢查變量作爲參數,它是ID並且它不爲空並且具有一個值。
感謝那些沒有工作:) –