java - Get value from Databse and outprint if or else statement based on selection from ComboBox -
db information db name contact row answer bool in sqlite
values in row 0 or 1 0 false , 1 true
combobox name answercall
textfield name textacall
upon selection of jcombobox
want
system.out.println ("do not answer!");
or
system.out.println("answer call!");
into textfield
as of right printing console
not textfield
, prints out answer call! no matter selection of combobox is.
i appreciate if me correct this.
private void answercallactionperformed(java.awt.event.actionevent evt) { string ans= (string) answercall.getselecteditem(); try { string sql = "select * contact answer='"+ans+"'"; pst = conn.preparestatement(sql); rs = pst.executequery(); if (ans.equals("1")) { textacall.settext(ans); system.out.println ("do not answer!"); } else { system.out.println("answer call!"); } } catch(exception e) { joptionpane.showmessagedialog(null, e); } }
i ans not think is. place system.out.println("'" + ans + "'"); line before if statement.
Comments
Post a Comment