SQL Command To Delete Entry In Current Textfields For Java App -
i have java program connect database running tomcat. app includes fields first name, last name, email, phone. created button when clicked allows add entries in text fields database.
below have shown structure of adding entry. use same method removing client entry. problem sql command. not sure how write it.
question: need sql command (like adding client) can have data database loaded in fields , take info , delete specific entry in database. please help.
insert client (in queries class):
//create insert adds new entry database insertnewperson = connection.preparestatement( "insert addresses " + "(firstname, lastname, email, phonenumber ) " + "values (?, ?, ?, ?)" );
method add person (in queries class):
//add entry public int addperson( string fname, string lname, string email, string num) { int result = 0; //set parameters, execute insertnewperson try { insertnewperson.setstring(1, fname); insertnewperson.setstring(2, lname); insertnewperson.setstring(3, email); insertnewperson.setstring(4, num); //insert new entry; return # of rows updated result = insertnewperson.executeupdate(); }//end try catch(sqlexception sqlexception) { sqlexception.printstacktrace(); close(); }//end catch return result; }//end method addperson
action performed (in application class , gui):
//handles call when insertbutton clicked private void insertbuttonactionperformed(actionevent evt) { int result = personqueries.addperson(firstnametextfield.gettext(), lastnametextfield.gettext(), emailtextfield.gettext(), phonetextfield.gettext()); if (result == 1) joptionpane.showmessagedialog(this,"person added!", "person added", joptionpane.plain_message); else joptionpane.showmessagedialog(this, "person not added!", "error", joptionpane.plain_message); browsebuttonactionperformed(evt); }//end method insertbuttonactionperformed
if understand correctly:
delete addresses firstname = <your value here> , lastname = <your value here> , email = <your value here> , phonenumber = <your value here>
this delete addresses
conditions true.
a more elegant solution 1 delete row primary key.
Comments
Post a Comment