aspose file tools
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

Win a copy of Groovy Fundamentals video training course this week in the Groovy forum!
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.

It is sorta covered in the JavaRanch Style Guide.
subject: How to get the table column names