Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding query execution

 
mahesh amber
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi to all,
I am not able to get idea
if we write a program in a java
that executes a sql query and we dont know how many colums does this has
and we have to display data along with column names
please note that
the query may be different and different colums for each execution

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will need to examine the result set's "meta" data to find out its structure. If you look at the documentation for java.sql.ResultSet you should be able to spot a way of doing this.
 
Srilakshmi Vara
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using ResultMetaData class which has getColumnCount() method which returns number of columns in the resultset and note that column count starts from 1.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic