java - MySQL error store boolean value into tinyint -
class code
this of code class code may help.
private resultset rs; private connection cn; private statement st; public void insertdata(string data) { try { st.executeupdate(data); { joptionpane.showmessagedialog(null, "data berhasil disimpan"); } } catch(exception e) { joptionpane.showmessagedialog(null, "gagal insert data"); } }
insertdaftar class
public class insertdaftar implements daftarinterface { public string nama; public boolean kuasa; code cd = new code(); public void setnama(string nama){ this.nama=nama; } public void setkuasa(boolean kuasa){ this.kuasa=kuasa; } public void akun(){ string data = "insert akun (nama,kuasa)"+"values('"+this.nama+"','"+this.kuasa+"')"; cd.insertdata(data); }
i have created code boolean
radio button.
boolean akun_kuasa; if (admin.isselected()){ akun_kuasa=true; } if (teller.isselected()){ akun_kuasa=false; } //todo insertdaftar id = new insertdaftar() id.setnama(akun_nama.gettext()); id.setkuasa(akun_kuasa);
there warning message on
id.setkuasa(akun_kuasa);
warning in netbeans.
initialize variable of akun_kuasa
i have tried change type of "akun_kuasa" int
, , changed akun_kuasa 0 , 1, there still error.
i have searched problem. there many boolean or tinyint.
note: id object have method store database.
akun_kuasa can undefined after if's
set false first? u know
it compiler warning u
akun_kuasa declared potentially undefined
when u call setter
Comments
Post a Comment