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();
大家好,我收到以下异常
Hi All, I am getting following exception
[jcc][10145][10844][3.63.123] Invalid parameter 1: Parameter index is out of range. ERRORCODE=-4461, SQLSTATE=42815
列限制为 255,路径为 = "C:Documents and SettingsxyzDesktopxyzs" 并且在语句中运行良好.那么,它在准备好的语句中抛出异常的原因是什么.
column limit is 255 and path is = "C:Documents and SettingsxyzDesktopxyzs" and it is run fine with statement.So , what is the reason that it is throwing exception in prepared statement.
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 + "%");
这篇关于使用准备好的语句进行选择查询时出现 SQL 异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!