Current location: Hot Scripts Forums » Programming Languages » Everything Java » ResultSetMetaData Methods

ResultSetMetaData Methods

Reply
  #1 (permalink)  
Old 04-26-04, 08:56 AM
Nerddette Nerddette is offline
Newbie Coder
 
Join Date: Apr 2004
Location: Australia
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
ResultSetMetaData Methods

I have been given the following snippet of code, which is part of a ResultSetModel.java file which is used by a file which uses JDBC/SQL data.

Code:
public String getColumnName (int columnIndex) {
        ResultSetMetaData  resultSetMetaData = resultSet.getMetaData();
        //Put some program code here. (They put this in, not me :))
    }
It then tells me to "use one of its methods, so that the above function returns an appropriate heading for each column. "

The GUI columns currently show as the defaults (a-e) and instead I want them to show ComNum, FirstName, Surname, Gender, CountryCode.

Any ideas???

Nerddette

Last edited by Nerddette; 04-26-04 at 09:05 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 04-26-04, 11:13 AM
stdunbar stdunbar is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Superior, CO, USA
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
If I understand your question correctly I think you want to use the getColumnName() method on ResultSetMetaData (see http://java.sun.com/j2se/1.4.2/docs/...tMetaData.html for more information)

Your comment line below would be replaced by:

return( resultSetMetaData.getColumnName( columnIndex ) );


Quote:
Originally Posted by Nerddette
I have been given the following snippet of code, which is part of a ResultSetModel.java file which is used by a file which uses JDBC/SQL data.

Code:
public String getColumnName (int columnIndex) {
        ResultSetMetaData  resultSetMetaData = resultSet.getMetaData();
        //Put some program code here. (They put this in, not me :))
    }
It then tells me to "use one of its methods, so that the above function returns an appropriate heading for each column. "

The GUI columns currently show as the defaults (a-e) and instead I want them to show ComNum, FirstName, Surname, Gender, CountryCode.

Any ideas???

Nerddette
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 05-06-04, 11:54 PM
oh_maan oh_maan is offline
New Member
 
Join Date: May 2004
Location: trichur,kerala
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
ResultSetMetaData class has a method called getColumn Name...u se that to get the name of the column with which u are workin...resultSet intially points to a empty column..u'll have to do resultSet.next to make it point to the first row.


Quote:
Originally Posted by Nerddette
I have been given the following snippet of code, which is part of a ResultSetModel.java file which is used by a file which uses JDBC/SQL data.

Code:
public String getColumnName (int columnIndex) {
        ResultSetMetaData  resultSetMetaData = resultSet.getMetaData();
        //Put some program code here. (They put this in, not me :))
    }
It then tells me to "use one of its methods, so that the above function returns an appropriate heading for each column. "

The GUI columns currently show as the defaults (a-e) and instead I want them to show ComNum, FirstName, Surname, Gender, CountryCode.

Any ideas???

Nerddette
__________________
There are 10 types of people in this world.. those who understand binary and those who dont!

R.Sreeram
Final Year B.Tech CSE
National Institute Of technology
Warangal - 506004
A.P
India

Ph# 9440313620
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 05:00 PM.
vBulletin® Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.