4 Replies Latest reply: Nov 8, 2006 7:39 AM by 807607 RSS

    Prepared Statement invalid parameter index

    807607
      Hello,

      i�ve a problem executin the following prepared statement:
      PreparedStatement pstmt=context.getConnConn().prepareStatement("select destination,mailscan,login from N4U_rebuild2005_virtuser_temp where emailart='mailbox' and mailscan='V' and email='?' and domain='?' and session=?");
      when i�m running throu the code:
      pstmt.setString(1, email);
      pstmt.setString(2, domain);
      pstmt.setLong(3, sessionOid.longValue());
      i get an error on the second line:
      java.sql.SQLException: Invalid parameter index 2.
      at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.getParameter(JtdsPreparedStatement.java:255)
      at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setParameter(JtdsPreparedStatement.java:326)
      at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setString(JtdsPreparedStatement.java:606)

      But why, cause i�ve 3 placeholders with the
      ?
      sign?

      Thx a lot