JComboBox only show one item from database

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 00:43:12
Priyamal
        Vector v = new Vector();
        while (resultSet.next()){
            String list = resultSet.getString("itemname");
            v.add(list);

        }
        conn.close();
        purcItemName.setModel(new DefaultComboBoxModel(v));

store the data you got from database in a vector object and once that is completed set the vector object in your combobox as a new model. try this one and don't close the connection inside your loop.

you are closing connection inside resultSet.next() check, put the conn.close() outside, to the end

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!