Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

rs.getString index start @ 1

 
R Sawant
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just wondering, why the index starts at 1 while using "java.sql.ResultSet.getString()" from JDBC API
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
R Sawant
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20529
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
R Sawant
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob... Just made sure there is no computer science fundamental involved here
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic