aspose file tools*
The moose likes JDBC and the fly likes java.sql.sqlexception invalid column index Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.sql.sqlexception invalid column index" Watch "java.sql.sqlexception invalid column index" New topic
Author

java.sql.sqlexception invalid column index

charu latha
Ranch Hand

Joined: Aug 20, 2002
Posts: 67


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

Joined: Jun 01, 2010
Posts: 618
Can you post all of the code?
charu latha
Ranch Hand

Joined: Aug 20, 2002
Posts: 67
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
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

Joined: Aug 20, 2002
Posts: 67
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

Joined: Jun 01, 2010
Posts: 618
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.
 
wood burning stoves
 
subject: java.sql.sqlexception invalid column index