File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes How to get the table column names Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "How to get the table column names" Watch "How to get the table column names" New topic

How to get the table column names

Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
How to get table column name using ResultsetMetadata if there is no record present in the table.Thanks

Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
I don't think having an empty resultset prevents you from accessing the ResultSetMetaData object. Have you tried it?

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Sainudheen Mydeen
Ranch Hand

Joined: Aug 18, 2003
Posts: 218
You can get the column names from ResultSetMetaData even if your resultset is empty. For example if your quey is

Still you will be able to get column names from the corresponding ResultSetMetaData.

I agree. Here's the link:
subject: How to get the table column names
It's not a secret anymore!