Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the following Oracle error mean: invalid column index

Tags:

java

sql

oracle

I got the following error while testing some code:

SQLException: Invalid column index

What exactly does that mean?

Is there an online document explaining what all the Oracle error codes and statements?

like image 879
jdbcnewbie. Avatar asked May 11 '11 18:05

jdbcnewbie.


People also ask

What does invalid column index mean?

The most common cause of "java. sql. SQLException: Invalid column index" is a misconception that column index started with "0" like array or String index but that's not true instead column index starts with "1" so whenever you try to get or Set column data with column index "0" you will get "java. sql.

How to fix java SQL SQLException Invalid column index?

Description. Main reason of SQLException:Invalid Column Index is either you are trying to read an invalid column index from result set returned by Query or you are setting parameter on parametric prepared Statement on invalid index using getString or setString method.


1 Answers

If that's a SQLException thrown by Java, it's most likely because you are trying to get or set a value from a ResultSet, but the index you are using isn't within the range.

For example, you might be trying to get the column at index 3 from the result set, but you only have two columns being returned from the SQL query.

like image 95
Datajam Avatar answered Sep 19 '22 06:09

Datajam