java.sql.SQLException:Parameterindexoutofrange(1>numberofparameters,whichis0).atcom.mysql.jdbc.SQLError.createSQLException(SQLError.java:963)atcom.mysql.jdbc.SQLError.cre…
java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:963)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:896)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:885)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
程序是 public Search search (String SYS_NAME, String IP, String SYS_LEVEL, String OWNERA, String OWNERB, String SYS_DESC, String SYS_DATE, String RECORDER) {
SQL =”Select s.SYS_NAME, i.IP, s.SYS_LEVEL, s.OWNERA, s.OWNERB, s.SYS_DESC, s.SYS_DATE, s.RECORDER from sms_system s, sms_sysip i where s.S1=i.S1 and s.SYS_NAME like (‘%name%’) and i.IP like (‘%ip%’)”;
Connection connection = null;
PreparedStatement pstmt = null;
try {
connection = DbUtil.getConnection();
pstmt = (PreparedStatement) connection.prepareStatement(SQL);
pstmt.setString(1, SYS_NAME);
pstmt.setString(2, IP);
pstmt.setString(3,SYS_LEVEL);
pstmt.setString(4,OWNERA);
pstmt.setString(5,OWNERB);
pstmt.setString(6,SYS_DESC);
pstmt.setString(7,SYS_DATE);
pstmt.setString(8,RECORDER);
ResultSet rSet = (ResultSet) pstmt.executeQuery();
if (rSet.next()) {
sea.setSYS_NAME(rSet.getString(“SYS_NAME”));
sea.setIP(rSet.getString(“IP”));
sea.setSYS_LEVEL(rSet.getString(“SYS_LEVEL”));
sea.setOWNERA(rSet.getString(“OWNERA”));
sea.setOWNERB(rSet.getString(“OWNERB”));
sea.setSYS_DESC(rSet.getString(“SYS_DESC”));
sea.setSYS_DATE(rSet.getString(“SYS_DATE”));
sea.setRECORDER(rSet.getString(“RECORDER”));
}
求教为什么会索引越界,谢谢
展开
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/213214.html原文链接:https://javaforall.net
