Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pulling the table names from a Database

 
ben riches
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
The code below displays 2 comboBoxes and puts the data from each table into the pull downs. How can I get it so that the first comboBox displays all the tables in my dataBase and the second comboBox dispalys the column names from the table the user has selected from the first comboBox?
Thanks
ben
 
Tom Blough
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at DatabaseMetaData. The method getTables will return the information for your first listbox. The method getColumns will return the information for your second listbox based on the table selected in the first list.
Tom Blough
 
ben riches
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tom Blough:
Have a look at DatabaseMetaData. The method getTables will return the information for your first listbox. The method getColumns will return the information for your second listbox based on the table selected in the first list.
Tom Blough

Hi Tom,
I have been able to get the table names fro the Database with this code

But when I am having trouble to get the Column names from the table the user has selected, could you help me with this part please.
Thanks
ben
 
Tom Blough
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben,
See if this helps:

[ March 10, 2004: Message edited by: Tom Blough ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic