Parameter index out of range error
i have a PreparedStatement I construct using this for loop:
preparedStatement ="insert into ? values('?','?','";
int numberOfMnemonics = mnemonicList.size();
for(int i=0;i<numberOfMnemonics-1;i++){
preparedStatement +="? '" + COMMA +"' ";
}
preparedStatement +="?');";
the 'numberOfMnemonics' field is usually somewhere around 50-75.
Then I run the following code:
PS = conn.prepareStatement(preparedStatement);
PS.setString(1,tableName);
PS.setString(2,count);//count is just an int
on the second line I get the following error:
java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1).
why is this? Do i need to insert the '?' into the PreparedStatement string in a
different way? What am i missing here? I need to be able to fill in those other 60+ parameters as well.
Thanks

