This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund 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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply 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!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Retrieve MySQL table column names
 
Similar Threads
how to get top 5 result from database
Primary Key contains "#" sign
MySQL naming conventions?
Problem with JTable
MySQL Case Sensitive Problem