• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem while updating values in table  RSS feed

 
vinoth vino
Ranch Hand
Posts: 67
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Programmers, Now i came to preparedStatement and here i m updating some values but it shows me an exception....
I'm having one doubt about updating values to preparedStatement "should i want to initialize the all column names which are in emp5 table for updating values ?"

CODE SNIPPET



output
java.sql.SQLException: Parameter index out of range (3 > number of parameters, which is 2).
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:937)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:872)
at com.mysql.jdbc.PreparedStatement.checkBounds(PreparedStatement.java:3367)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3352)
at com.mysql.jdbc.PreparedStatement.setString(PreparedStatement.java:4078)
at demojdbc.MysqlCon.main(MysqlCon.java:21)



error.png
[Thumbnail for error.png]
Records in the emp5 table
 
Campbell Ritchie
Marshal
Posts: 56223
171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't the answer obvious from the error message?
 
vinoth vino
Ranch Hand
Posts: 67
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I m trying to update "karthi" to 3rd column(fname) where id = 6 of emp5 table in 6th row @champ
 
Campbell Ritchie
Marshal
Posts: 56223
171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are trying to update the 1st argument to the prepared statement.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!