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 option elements combo box value being id , label being name of company
  • configure onchange event on combo box, here's example
  • write javscript function update value in combo box in onchange event configured in previous step (here's example of how update value)

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -