What does the following Oracle error mean: invalid column index

后端 未结 8 999
你的背包
你的背包 2020-12-17 08:09

I got the following error while testing some code:

SQLException: Invalid column index

What exactly does that mean?

Is

8条回答
  •  执念已碎
    2020-12-17 08:17

    I had this problem in one legacy application that create prepared statement dynamically.

    String firstName;
    StringBuilder query =new StringBuilder("select id, name from employee where country_Code=1");
    query.append("and  name like '");
    query.append(firstName + "' ");
    query.append("and ssn=?");
    PreparedStatement preparedStatement =new prepareStatement(query.toString());
    

    when it try to set value for ssn, it was giving invalid column index error, and finally found out that it is caused by firstName having ' within; that disturb the syntax.

提交回复
热议问题