2

I have 10 parameters set in the statement with the question marks and provided 10 associated values. At execution, it’s throwing this error “org.postgresql.util.PSQLException: No value specified for parameter 11.” I’m having a similar issue with another table where it’s also asking for an out of range parameter. I can manually run the query against PostGres without any problem. Please see log below, thanks in advance.

[DBOperations]:INSERT INTO product.SHIB_RP_MD_PROVIDER(RP_MD_PROVIDER_ID,MD_PROVIDER_TYPE_ID,MD_ID,SRC_ORG_ID,MD_NAME,MD_DESC,PARENT_RP_MD_PROVIDER_ID,LAST_UPDATE_USER,LAST_UPDATE_DATE,SYSTEM_IND,ORG_ID) VALUES (?,?,?,?,?,?,?,?,date_trunc('second' , now()),?,?)

[DBOperations]:No value specified for parameter 11. org.postgresql.util.PSQLException: No value specified for parameter 11.

[DBOperations] - Index 1 - Value 10042
[DBOperations] - Index 2 - Value 4
[DBOperations] - Index 3 - Value aa
[DBOperations] - Index 4 - Value 2
[DBOperations] - Index 5 - Value aa
[DBOperations] - Index 6 - Value null
[DBOperations] - Index 7 - Value 0
[DBOperations] - Index 8 - Value 1234
[DBOperations] - Index 9 - Value 0
[DBOperations] - Index 10 - Value 2
1
  • 1
    you actually have 11 parameters. did you put in an extra one by accident? Commented May 6, 2016 at 14:42

2 Answers 2

3
   INSERT INTO dah53idm.SHIB_RP_MD_PROVIDER(RP_MD_PROVIDER_ID,MD_PROVIDER_TYPE_ID,
    MD_ID,SRC_ORG_ID,MD_NAME,
    MD_DESC,PARENT_RP_MD_PROVIDER_ID,
    LAST_UPDATE_USERID,
    LAST_UPDATE_DATE,
    SYSTEM_IND,ORG_ID) VALUES (?,?,?,?,?,?,?,?,date_trunc('second' , now()),?,?)

well answer is pretty obvious . but i'll point it out anyway, you have 11 question marks which means you are supposed to add 11 values to execute the query but in your code you are adding only 10 , hence the exception "no value specified for 11"

Sign up to request clarification or add additional context in comments.

3 Comments

I counted only 10 question marks. I'm passing in date_trunc('second' , now()) for one of the columns. Therefore I'm assuming I don't need to put a question mark for that.
replace that part with a ? and add values later.
dont add values to 9 add values to 10 and 11 straightaway
0

assign all the parameters to the values properly

for (User user : users) {
    System.out.println("Inserting Data for Userr name" + user.getName());
    jdbcTemplate.update("insert into USERR(Id,Name,Dept,Salary) 
    values(?,?,?,?)",
    preparedStatement -> {
        preparedStatement.setLong(1,user.getId());
        preparedStatement.setString(2, user.getName());
        preparedStatement.setString(3, user.getDept());
        preparedStatement.setLong(4, user.getSalary());

    });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.