Dylan
Dylan

Reputation: 955

Parameter index out of range MySQL PreparedStatement?

I try to do a select:

enter image description here

but I receive an Exception: enter image description here

Upvotes: 0

Views: 298

Answers (2)

Srinu Chinka
Srinu Chinka

Reputation: 1491

You are creating PrepareStatement object at line number 212 but you are not assigning to the prepareStatement variable, which means prepareStatement variable still holds old object.

At line number 213 you are using setInt() method, it'll calls the old object. It seems your old object contains any place holders, because of the this reason you got Parameter index out of range exception.

Assign the newly created PreparedStatement object to prepareStatement variable at line number 212 to resolve your problem.

Upvotes: 1

fab
fab

Reputation: 1259

Try it like that:

preparedStatement = connection.prepareStatement(sqlCompetition);
preparedStatement.setInt(...);

I think you have still the old statement in the variable

Upvotes: 2

Related Questions