Originally posted by Seetesh Hindlekar: Hi, When used, gives Invalid Column index. Is 0 reserved for some variable? Why only the ResultSet.getxxxx(1) has to start from column index from 1 onwards. Seetesh
I suppose this is a "because it does, so just accept it" answer. The JDBC API designers made a decision at some point that the column indexes would be base-1 instead of base-0 like you were expecting. I wish all index-related methods were base-0 for consistency reasons. It is kind of annoying to have to remember which methods use 0 and which use 1. You just get used to it after a while. :roll:
Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
Joined: Feb 13, 2004
Hi Blake, ----------- ur post ---------------- You just get used to it after a while. ------------ end of post ---------------- Can u come up with a good solution instead of the statement made? Its mentioned in the JDK help that the column nos start from 1 onwards. BTW, My question is still not answered. Rgds, Seetesh
Hi Satish, well I think your question was answered by blake...more or less,(even the resultset itself does not have a row 0, you have to call on the resultset.next() to get to the first row.) besides, the Drivers are not developed by sun, they are developed by the database vendors or atleast depend on the ODBC standard,...so it could just be a generally accepted standard.... I dont know but 0 might also have been reserved for some special reasons, some databases support indexing of the records, which can be queried also, but they do not form the structure of the table....then probably when you make some special Queries the 0 will have some indexed info?? Or it could just be that they stuck to Natural Numbers. some SQL expert could actually compare the Resultset and a Cursor in the RDBMS world, that could be a good insight too. resukt of getString(0)\ java.sql.SQLException: Invalid column index at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269) at oracle.jdbc.driver.OracleStatement.prepare_for_new_get(OracleStatement.java:3199) at oracle.jdbc.driver.OracleStatement.getIntValue(OracleStatement.java:4264) at oracle.jdbc.driver.OracleResultSetImpl.getInt(OracleResultSetImpl.java:510) at test.datalayer.DbConnection.main(DbConnection.java:92) [ April 01, 2004: Message edited by: RajaniKanth Bhargava ]