1. 程式人生 > >java.sql.SQLException: Parameter index out of range (4 > number of parameters, which is 2).

java.sql.SQLException: Parameter index out of range (4 > number of parameters, which is 2).

背景: 在使用多執行緒測多個基站(一個基站下面多個手卡)的資料,雖然資料都接受沒有問題,但是報了這個錯誤。 java.sql.SQLException: Parameter index out of range (4 > number of parameters, which is 2). at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926) at com.mysql.jdbc.PreparedStatement.checkBounds(PreparedStatement.java:3657) at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3641) at com.mysql.jdbc.PreparedStatement.setString(PreparedStatement.java:4492) at cn.com.lf.JdbcUtils.update(JdbcUtils.java:70) at cn.com.gj.ThreadReader.othernum(ThreadReader.java:124) at cn.com.gj.ThreadReader.run(ThreadReader.java:39) at java.lang.Thread.run(Thread.java:722) 在這裡插入圖片描述

問題說明: 很好理解,注入引數的時候發生錯誤,那肯定就是自己寫的sql有問題了。