我知道如何从数据库中的数据的Java应用程序,但我的问题是增加了数据的JComboBox,我这样做: main.java:设置项目的JComboBox
`Interface itself = new Interface();
itself.setComboBoxItems();`
//调用该方法setComboBoxItems
这里是法setComboBoxItems():
public void setComboBoxItems() {
ResultSet rset = null;
Statement stmt = null;
Connection connect = null;
try {
stmt = connect.createStatement();
rset = stmt.executeQuery("SELECT * FROM DB_Library.dbo.categories");
while(rset.next()) {
String comboItem = rset.getString("categoryName");
System.out.print("now combobox items will run!");
categoriesComboBox.addItem(comboItem);
}
} catch (SQLException ex) {
System.out.print("error from set ComboBox: ");
Logger.getLogger(Interface.class.getName()).log(Level.SEVERE, null, ex);
}
}
但它返回这个错误对我来说,我解决不了,
你会得到什么错误? – u449355
告诉我们'ex.printStackTrace()' – oliholz
'接口本身=新接口();'使小猫哭。 – Qwerky