Java Eclipse GUI Tutorial 18 # How to link JList with Sqlite database in Java

Поділитися
Вставка
  • Опубліковано 19 вер 2024
  • Donate to ProgrammingKnowledge -- (www.paypal.com...)
    A simple JList example
    An example of JList with a DefaultListModel
    JList basic tutorial and examples
    How to use jList and link it to Database
    Verwandte Suchanfragen zu how to use jlist
    java jlist tutorial
    jlist single selection
    jlist getselectedindex
    swing table
    java sortable table
    swing tablemodel
    swing border
    jtable model

КОМЕНТАРІ • 5

  • @ProgrammingKnowledge
    @ProgrammingKnowledge  10 років тому +1

  • @makel7434
    @makel7434 7 років тому

    When i put jlist, its not visible and doesn't work... How solve?

  • @dwightretulla4995
    @dwightretulla4995 4 роки тому

    try {

    String sql = "SELECT * FROM PMS";
    PreparedStatement pst = con.prepareStatement(sql);
    DefaultListModel model = new DefaultListModel();

    while (rst.next()) {
    String namelist = rst.getString("FIRSTNAME");
    model.addElement(namelist);
    }

    listtxt.setModel(model);
    pst.close();
    rst.close();

    } catch (SQLException e) {

    }
    }
    why am i not getting nothing? i already added the method name to the constructor.

  • @johnpeabody8575
    @johnpeabody8575 5 років тому

    how do you avoid duplicates on the list?

    • @johnpeabody8575
      @johnpeabody8575 5 років тому

      answered: change your query to "select DISTINCT column_name from table_name"