mysql - Querying DB Continuously for Update - java -
i have query fetch name , id of companies. able fetch companies issue id of companies. have combo box display list of companies , label displays id of company selected in combo box.
here issue, when change selected company in combo box, label showing id still remains displays id of initial company selected. there way continuously query database update id?
ps display companies in combo box reference no.
public assigncompanies() { initcomponents(); conn = dbconnection.connectdb(); findcompanyid(); } public void findcompanyid() { string sql = "select * company id = "+findselectedcompany.getselecteditem(); try { statement stmt = conn.createstatement(); resultset rs = stmt.executequery(sql); while(rs.next()) { string getselectedcompany = rs.getstring("reference number"); seats.settext(getselectedcompany); } }
you don't need query database everytime user changes selection in combo box, can following:
- get ids , names of companies, , dynamically add
optionelements combo boxvaluebeingid,labelbeingnameof company - configure
onchangeevent on combo box, here's example - write javscript function update value in combo box in
onchangeevent configured in previous step (here's example of how update value)
Comments
Post a Comment