wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes rs.getString index start @ 1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "rs.getString index start @ 1" Watch "rs.getString index start @ 1" New topic
Author

rs.getString index start @ 1

Ramdas Sawant
Ranch Hand

Joined: Aug 08, 2005
Posts: 51
Just wondering, why the index starts at 1 while using "java.sql.ResultSet.getString()" from JDBC API


If you think you can, you can. If you think you can't, you are right.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Ramdas Sawant wrote:Just wondering, why the index starts at 1 while using "java.sql.ResultSet.getString()" from JDBC API

Ok, then where should it start from ? Just do not get confused with array index and tables column index.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Ramdas Sawant
Ranch Hand

Joined: Aug 08, 2005
Posts: 51
What I really meant is why there is lack of consistency... What could have happened if table col index starts at 0 ??
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

It's a design decision, probably inspired by stored procedures in database systems that also start at 1. It's not that big of a deal as long as you remember the different offset.

Offtopic: if you want inconsistency, check out Calendar.JANUARY and Calendar.SUNDAY. Same class, two different offsets.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ramdas Sawant
Ranch Hand

Joined: Aug 08, 2005
Posts: 51
Thanks Rob... Just made sure there is no computer science fundamental involved here
 
GeeCON Prague 2014
 
subject: rs.getString index start @ 1