This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Resultset getter method problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Resultset getter method problem" Watch "Resultset getter method problem" New topic
Author

Resultset getter method problem

Sujoy Mukherjee
Ranch Hand

Joined: Dec 31, 2005
Posts: 46

hi all,
while displaying results using resultset, we generally write the following lines of code:


My question is, suppose there is a big table with 20 columns and I want to show all of them. So instead of showing them using the gettermethod(index1) +gettermethod(index2)+gettermethod(index3)......and so on till 20th column...., can we show the whole row in one shot? Is there any alternative way for this?

Thanking in advance.

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

Not directly. If you know the number of columns, you could write a form loop so you don't have to type out the logic.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Sujoy Mukherjee
Ranch Hand

Joined: Dec 31, 2005
Posts: 46

Thanks for replying.
I know I can use getColumnCount() method of ResultsetMetdata interface to know the column number. But then?
I have tried something like this:


But then again, I have to display each column separately within the while loop using the getter methods and the index value of the columns which I don't want. I mean if there are 20/30 columns in a table and if there is a need to print them all then I have to type each of them for 20/30 times using the getter methods.
Is there a way so that I can put the data of a Row inside some Class and print the column values separately?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Resultset getter method problem
 
Similar Threads
is there a any validation API in java
Can't return data from MSSQL 2008 named instance
Another DefaultTableModel post
Need Code Review
Resultset