I'm trying to populate my JComboBox with data in my database with the use of arraylist but sadly there must be a mistake in my code can some help me Please and btw my connection is working well.
In my table (tblcuri) i have 3 fields (fldCurId,fldSy,fldDescp). i want to fldDescp to be displayed in my JComboBox but i don't know how.. Please Help me i'm only a 3day old java use
---------------------------------------------------------------------------------
Code in my dbFunction class:
public List getCurriculum() {
ResultSet rsRec;
List curriculum = new ArrayList();
String sql;
sql = "select * from tblcuri order by fldDescp";
try {
rsRec = st.executeQuery(sql);
while (rsRec.next()) {
curriculum.add(rsRec.getString("fldDescp"));
}
rsRec.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
return curriculum;
}
----------------------------------------------------------------------------------------------
Code: (student Jframe Class) name of the JCombox(cbCurr)
public student() {
initComponents();
List cList = dbFunctions.getCurriculum();
cbCurr = new JComboBox();
Iterator<List> iterator = cList.iterator();
while (iterator.hasNext()) {
List list = iterator.next();
cbCurr.addItem(iterator.next());
}
}