java - passing and parsing object input dialog value to database table -
i want know how integer value input dailog box
and query inside select statement looks error input box type per below object , have no idea how parse object integer accepted select statement please advise how handle object type inputbox variables , inject same select
private void inputval(){
// here input box retrieve user entry object journal_no = joptionpane.showinputdialog( null, "please enter journal no.?:\n", "search", joptionpane.plain_message, null,null,""); if (journal_no.equals("")){ joptionpane.showmessagedialog(null, "please enter correct no."); return; } // here call sql statement load table rely on //inputbox try { string host1= "jdbc:derby://localhost:1527//accountsdb"; string uname1="accounts"; string upass1="accounts"; con1=drivermanager.getconnection(host1,uname1 ,upass1); //string sql ="select * log password= jtuser.gettext() " ; string sql1="select * jounral journal_no=" + journal_no + " "; stmt1=con1.createstatement(resultset.type_scroll_sensitive, resultset.concur_updatable); rs=stmt1.executequery(sql1); while (rs.next()){ //load values date jdate =rs.getdate("journal_date"); txt_date.setdate(jdate); int jno; jno = rs.getint("journal_no"); jljournal_no.settext(integer.tostring(jno)); } } catch (sqlexception ex) { system.out.println(ex.getmessage()) ; } }
if int use int journalno = integer(objectvalue);
else convert string , int. able catch numberformatexception in case.
object string:
string journalnumber = objectvalue.tostring();
string int:
int journalnumberasint = integer.parseint(journalnumber);
Comments
Post a Comment