Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to fix java.sql.SQLException: Invalid column index? Example

How To Fix Java.sql.SQLException: Invalid Column Index? Example
"java.sql.SQLException: Invalid Column index" is a frequent error while working in Java Database Connectivity (JDBC). As the name suggests "Invalid column index" its related to accessing or setting column in your SQL Query using prepared statement in Java. I have seen "java.sql.SQLException: Invalid column index" coming mostly due to two reason:

1) Setting column data using setXXXX(int coloumIndex) e.g. setInt(0) setString(0)
2) Getting column data using getXXX(int columnIndex) e.g. getInt(0) getString(0)

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.SQLException: Invalid column index".


This post first appeared on Javarevisited: Blog About Java Programmin, please read the originial post: here

Share the post

How to fix java.sql.SQLException: Invalid column index? Example

×

Subscribe to Javarevisited: Blog About Java Programmin

Get updates delivered right to your inbox!

Thank you for your subscription

×