我正在尝试从数据库中获取信息以填充 Jcombobox,我正在尝试使用以下代码,但它们不起作用,在所有这些代码中,组合框都没有被清理。
第一次尝试
try {
con = Connectionz.getConnection();//Connection Object
pst = con.prepareStatement("SELECT * AS achooserfill FROM Login_Users WHERE [C Team Lead] =?");
pst.setString(1, va);
rs = pst.executeQuery();
while (rs.next()) {
achooser.removeAll();
achooser.addItem("Please select agent");
achooser.addItem(rs.getString("achooserfill"));
}
}catch(Exception e){
System.err.println(e);
}
第二次尝试
try {
con = Connectionz.getConnection();//Connection Object
pst = con.prepareStatement("SELECT * FROM Login_Users WHERE [C Team Lead] =?");
pst.setString(1, va);
rs = pst.executeQuery();
while (rs.next()) {
achooser.removeAll();
achooser.addItem("Please select agent");
achooser.addItem(rs.getString("[VA #]"));
}
}catch(Exception e){
System.err.println(e);
}
第三次尝试
try {
con = Connectionz.getConnection();//Connection Object
pst = con.prepareStatement("SELECT [VA #] FROM Login_Users WHERE [C Team Lead] =?");
pst.setString(1, va);
rs = pst.executeQuery();
while (rs.next()) {
achooser.removeAll();
achooser.addItem("Please select agent");
achooser.addItem(rs.getString("[VA #]"));
}
}catch(Exception e){
System.err.println(e);
}
在所有情况下,结果都是一样的,
我真的很感激任何类型的信息或任何资源来解决这种情况
精慕HU
慕桂英546537
相关分类