mysql - How to combine multiple nric and make them into a joined account ? Using Java-EE -
i trying merge individual nric 1 user have registered website , after combine them 1 single account, user can have family account created. using java ee codes , faced issue , appreciate help!
how works:
1) user keys in different nric , data stored table in mysql database
2) unique code generated , stored table in table each successful account created
3) system retrieve info , there create joined account.
here's snippet of code:
calling servlet
public familyaccountservlet() { super(); // todo auto-generated constructor stub } /** * @see httpservlet#doget(httpservletrequest request, httpservletresponse response) */ protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { // todo auto-generated method stub } /** * @see httpservlet#dopost(httpservletrequest request, httpservletresponse response) */ protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { // todo auto-generated method stub familyaccount myfam = new familyaccount(); myfam.setfamilyname(request.getparameter("txtfamilyname")); myfam.setfnric1(request.getparameter("txtfnric1")); myfam.setfnric2(request.getparameter("txtfnric2")); myfam.setfnric3(request.getparameter("txtfnric2")); { try { httpsession mysess = request.getsession(true); mysess.setattribute("fam_info", myfam); dbao mydatabase = new dbao (); mydatabase.regmember(myfam); request.getrequestdispatcher("home.jsp").forward(request, response); } catch(exception ex) { } } } }
calling database (to insert data mysql )
public void regmember (familyaccount myfam) throws exception { try { string insertstatement = "insert familyok.family account (familyname, fnric1, fnric2, fnric3)"; insertstatement = insertstatement+ "values (?,?,?,?)"; preparedstatement prepstmt = con.preparestatement(insertstatement); prepstmt.setstring(1,myfam.getfamilyname()); prepstmt.setstring(2, myfam.getfnric1()); prepstmt.setstring(3, myfam.getfnric2()); prepstmt.setstring(4, myfam.getfnric3()); int status = prepstmt.executeupdate(); if(status!=0) { system.out.println("account created"); } }catch (exception ex) { throw new exception("error:"+ex.getmessage()); } }
jsp page
class/model
package model; public class familyaccount { private string fnric1; private string fnric2; private string fnric3; private string familyname; private char valid; public string getfnric1() { return fnric1; } public void setfnric1(string fnric1) { this.fnric1 = fnric1; } public string getfnric2() { return fnric2; } public void setfnric2(string fnric2) { this.fnric2 = fnric2; } public string getfnric3() { return fnric3; } public void setfnric3(string fnric3) { this.fnric3 = fnric3; } public string getfamilyname() { return familyname; } public void setfamilyname(string familyname) { this.familyname = familyname; } public char getvalid() { return valid; } public void setvalid(char valid) { this.valid = valid; } }
Comments
Post a Comment