StringBuilder sqlQry = new StringBuilder();
sqlQry.append("SELECT LIB, PATH")
.append(" FROM OBJ")
.append(" INNER JOIN SRC ON SRC.MBR = OBJ.LOBJ")
.append(" WHERE TYPE = '*PGM'")
.append(" AND SRC.PATH LIKE '").append("?").append("%'");
PreparedStatement ps = accssConn.prepareStatement(sqlQry.toString());
ps.setString(1, path);
rs = ps.executeQuery();
大家好, 我得到了以下异常
[jcc][10145][10844][3.63.123] Invalid parameter 1: Parameter index is out of range. ERRORCODE=-4461, SQLSTATE=42815
列限制为255,路径为=“C:\ Documents and Settings \ xyz \ Desktop \ xyzs”,并且使用statement.So运行正常,它在预准备语句中抛出异常的原因是什么。
答案 0 :(得分:3)
StringBuilder sqlQry = new StringBuilder();
sqlQry.append("SELECT LIB, PATH")
.append(" FROM OBJ")
.append(" INNER JOIN SRC ON SRC.MBR = OBJ.LOBJ")
.append(" WHERE TYPE = '*PGM'")
.append(" AND SRC.PATH LIKE ").append("?");
PreparedStatement ps = accssConn.prepareStatement(sqlQry.toString());
ps.setString(1, path + "%");
答案 1 :(得分:0)
检查你的单引号我认为其中一个缺少收盘报价。还可以尝试将单引号更改为双引号并将其转义为“* PGM”