Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Using MySQL Table Names for Combo Box

Reply
Thread Tools

Using MySQL Table Names for Combo Box

 
 
christopher_board@yahoo.co.uk
Guest
Posts: n/a
 
      06-14-2007
Hi all. I am trying to write a program where it has to connect to a
MySQL Database. Within the program there will be a drop down box that
will show class room names. In the datbase there is going to be a
table for each class room. I would like to add every table name within
a datbase into the drop down box if the java program. How would I go
about doing this.

Any help would be appreciated in this matter.

 
Reply With Quote
 
 
 
 
wisccal@googlemail.com
Guest
Posts: n/a
 
      06-15-2007
On Jun 14, 6:37 pm, (E-Mail Removed) wrote:
> Hi all. I am trying to write a program where it has to connect to a
> MySQL Database. Within the program there will be a drop down box that
> will show class room names. In the datbase there is going to be a
> table for each class room. I would like to add every table name within
> a datbase into the drop down box if the java program. How would I go
> about doing this.
>
> Any help would be appreciated in this matter.



How about something like this?

try {
Connection con = getConnection(); //Get you Connection object
DatabaseMetaData meta = con.getMetaData();
ResultSet rs = meta.getTables(null, null, "%", new String[]
{"Table"}); //Get only tables (no views, etc). You can adjust the 3rd
parameter to match only certain names.

while(rs.next()) {
String table = rs.getString(3);
System.out.println(table);
}
con.close();
} catch(Exception e) {
System.err.println("Exception: " + e.getMessage());
}

Regards,
Steve
------------------
www.stkomp.com

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to reference one combo box from another combo box SM Javascript 2 04-28-2007 04:49 PM
Fill Combo Box based on another Combo Box dthmtlgod ASP General 1 11-16-2005 04:08 PM
COMBO BOX INSTEAD OF DROP DOWN BOX =?Utf-8?B?QW5nZWw=?= ASP .Net 3 06-29-2004 06:38 PM
Populate List Box base on Combo Box Selection Adrian ASP General 1 02-18-2004 09:49 AM
Combo Box and text box Mike Javascript 2 09-24-2003 07:40 PM



Advertisments