add database Tablenames to the JList in java

Posted by Litecia on Stack Overflow See other posts from Stack Overflow or by Litecia
Published on 2010-05-17T03:18:15Z Indexed on 2010/05/17 3:20 UTC
Read the original article Hit count: 199

Filed under:

// Declare JList private JList jlstTab, jlstCol; . . . DefaultListModel dlmTables = new DefaultListModel(); DefaultListModel dlmCol = new DefaultListModel();

    // Instantiate 
    dlmTables.addElement("kl");
    jlstTab= new JList(dlmTables);
 jlstTab.setSelectedIndex(0);
    jlstTab.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

. . . .

Connect to the database public static void main(String args[]) { DBToolSwing cs = new DBToolSwing("DB Tool Swing"); try

              DBAccessObject dbAccess1 = new DBAccessObject("jdbc:odbc:JavaClassDSN");
      DBAccessObject dbAccess2 = new DBAccessObject();
              ResultSet rsTables = dbAccess1.getDatabaseTableNames();
      while (rsTables.next())
      System.out.println(rsTables.getString("TABLE_NAME"));

I need to get the table names from the database, the output shouldn't be printed on the screen, instead I need the output added to the JlstTab so dlmTables.addElement("TABLE_NAME"); Please if someone can help I would appreciate it. Thanks in advance.

© Stack Overflow or respective owner

Related posts about java