從我是否嘗試過如何從一個Oracle數據庫來的JComboBox負荷值,使之更容易爲用戶選擇這樣的:加載數據庫字段值的JComboBox
Connection dbcon = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
dbcon = DriverManager.getConnection("
jdbc:oracle:thin:@localhost:1521:XE", "USERNAME", "PASSWORD");
Statement st = dbcon.createStatement();
String combo = "Select EMP_IDNUM from employees";
ResultSet res = st.executeQuery(combo);
while(res.next()){
String ids = res.getString("EMP_IDNUM");
String [] str = new String[]{ids};
cboId = new JComboBox(str);
}
} catch (Exception d) {
System.out.println(d);
}
這只是讓我第一值放入JComboBox cboID。將整個字段數據(EMP_IDNUM)加載到Jcombobox中的最佳方法是什麼?
我無法相信有人是「足夠好」 DOwnvote我的問題Whle我只是Askng .. – ErrorNotFoundException