0
我要顯示我的數據庫的兩米欄分成兩個的JComboBox如何將數據從sql表中顯示到JComboBox中?
String rq1 = "SELECT region FROM rg";
String rq2 = "SELECT ACTELS FROM rg";
st1 = conn.createStatement();
st2 = conn.createStatement();
rs1 = st1.executeQuery(rq1);
rs2 = st2.executeQuery(rq2);
comboBox_ACTELS = new JComboBox<String>();
comboBox_gouver = new JComboBox<String>();
while ((rs1.next())&&(rs2.next())) {
String m1= rs1.getString("region");
String m2= rs2.getString("ACTELS");
//comboBox_gouver.setModel(new DefaultComboBoxModel<String>(new String[] {m1}));
//comboBox_ACTELS.setModel(new DefaultComboBoxModel<String>(new String[] {m2}));
comboBox_gouver.addItem(m1);
comboBox_ACTELS.addItem(m2);
nbp ++;
}
它是正確的? – 2012-04-11 11:39:28
問題是我有兩個班 – 2012-04-11 11:56:31
你能更好地描述你的問題嗎? – ray 2012-04-12 08:52:21