File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

rs.getString index start @ 1

 
R Sawant
Ranch Hand
Posts: 51
  • 0
  • 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: 2905
1
Java Spring Ubuntu
  • 0
  • 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
  • 0
  • 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: 20388
46
Chrome Eclipse IDE Java Windows
  • 0
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob... Just made sure there is no computer science fundamental involved here
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic