This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on resultset.getString(3)

 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, have a nice day, everyone, i understand the parameter for getString() method is columnindex , can someone tell me how to i determine the parameter is belongs to ?

in mycase , i have try on resultset.getString(3); which give me the tablename , is it the "3" belongs to tablename ?

thank you !
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alvin,
Three refers to the third column. It is good to make the column list explicity so that you aren't suprised by what it refers to. For example,
select col1, col2, col3 from table
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne, I believe Alvin is referring to DatabaseMetaData.

Alvin, have a look at Javadocs for java.sql.DatabaseMetaData

If you are getting the ResultSet by calling the getColumns() method, column number 3 refers to the table name.

cheers
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic