This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Retrieve MySQL table column names Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Retrieve MySQL table column names" Watch "Retrieve MySQL table column names" New topic
Author

Retrieve MySQL table column names

Bryan Scarbrough
Ranch Hand

Joined: Aug 08, 2005
Posts: 49
How can I get the column names from a MySQL table?


Bryan Scarbrough<br /> <br />Consistency is the last resort of the unimaginative!
Padma Lalwani
Ranch Hand

Joined: Nov 02, 2004
Posts: 49
Run the query as select *, get ResultSetMetaData from the ResultSet, use getColumnCount to get number of columns and then loop through to get name using getColumnName

Padma
Bryan Scarbrough
Ranch Hand

Joined: Aug 08, 2005
Posts: 49
Thanks, that was easier than I thought it would be!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Retrieve MySQL table column names
 
Similar Threads
Problem with JTable
MySQL naming conventions?
how to get top 5 result from database
Primary Key contains "#" sign
MySQL Case Sensitive Problem