Breaking News
Home / Java / Java Issues / java.sql.SQLException: Parameter index out of range

java.sql.SQLException: Parameter index out of range

Issue

Caused by: java.sql.SQLException: Parameter index out of range (0 < 1 ).
     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)<!>

com.mysql.jdbc.PreparedStatement.checkBounds(PreparedStatement.java:3712)
com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3701)
com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3743)
     at com.mysql.jdbc.PreparedStatement.setDate(PreparedStatement.java:3619)
     at com.mysql.jdbc.PreparedStatement.setDate(PreparedStatement.java:3588)
org.apache.commons.dbcp.DelegatingPreparedStatement.setDate(.Statement.java:141)
org.apache.commons.dbcp.DelegatingPreparedStatement.setDate(.Statement.java:141)
com.infuze.service.linkedin.dao.JobChangeDao.addUser(JobChangeDao.java:75)
com.infuze.service.linkedin.workflow.RegisterUserexecuteProcess(Register…java:76)
     … 10 more

Answer

When you set the values for the parameters in prepared statement make sure the index is correct. This error happens when you try to set a parameter with a index greater than the number of parameters. Also remember the index starts with a 0.

[pb_builder]

Check Also

Data truncation: Data too long for column – JDBC

Issue Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column ‘columname‘ at row 1     …

Advertisment ad adsense adlogger