• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Resultset getter method problem

 
Ranch Hand
Posts: 51
Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sujoy Mukherjee
Ranch Hand
Posts: 51
Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic