This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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: 19556
    
  16

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
 
 
subject: rs.getString index start @ 1
 
Similar Threads
Pattern Error while using RegEx
A EL Question
Image Blocks a Portion of the Sliding Menu from View
Radix Sort in descending order help
WA #1.....word association