Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.sql.sqlexception invalid column index

 
charu latha
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I have the above snippet of code in my class. It always throws a invalid column index . I have double checked my query to make sure that i am expecting only 5 parameters. I have tried hard coding the values and that query goes through without an issue. I have double checked to see if the values that i am setting in query are not null. That looks ok also.

Anyone shed any light on why i am getting this error?

Thanks
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post all of the code?
 
charu latha
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I only see 3 question marks in INSERT_CNTL_LIST_OWNER, which is why you are getting the error. You can't just refer to another String variable in a String and expect it to include it. Please respond if you need more information.
 
charu latha
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The two string variables are select clauses which need the other two parameters that i have set.

I have code that is working in production like this.


When the statement actually executes it will substitute the value of the other SQL statement that is referred to.

 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the statement actually executes it will substitute the value of the other SQL statement that is referred to.

No it won't. Try this. Comment out the statements:
And run it. You won't get invalid column index error but will get another SQL error.

Then try replacing the two String variables, SELECT_BULK_STATUS and SELECT_OWNER_SK, that you are referring to in your INSERT_CNTL_LIST_OWNER String with their actual values. Put back the two lines commented out above and rerun the test.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic