aspose file tools
The moose likes JDBC and the fly likes regarding query execution Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "regarding query execution" Watch "regarding query execution" New topic
Author

regarding query execution

mahesh amber
Greenhorn

Joined: Mar 11, 2008
Posts: 7
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

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Srilakshmi Vara
Ranch Hand

Joined: Jul 21, 2004
Posts: 169
Try using ResultMetaData class which has getColumnCount() method which returns number of columns in the resultset and note that column count starts from 1.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: regarding query execution
 
Similar Threads
DB Visualizer Execution Plan
Query Execution Time.
Resultset in session
Prepared Statement vs statement
Preparing a PreparedStatement