File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Question on resultset.getString(3) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Question on resultset.getString(3)" Watch "Question on resultset.getString(3)" New topic

Question on resultset.getString(3)

Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
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

Joined: May 26, 2003
Posts: 33125

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

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

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.

I agree. Here's the link:
subject: Question on resultset.getString(3)
It's not a secret anymore!