Hai everybody,
I am facing problem with updating a record .actullay im getting some data from database(Access ) and populating it on a html form.im trying to edit some texts and update, its not reflecting in database. here is the code.
(the request parameters from html form, there is no mismatch between variable names)
*************** *************** *************** *************** *************** *************** **private void updateEmployee( HttpServletRequ est request, HttpServletResp onse response) throws IOException{
PrintWriter out = response.getWri ter();
String firstname=reque st.getParameter ("firstname" );
String lastname=reques t.getParameter( "lastname") ;
String empid=request.g etParameter("em pid");
String extnnum = request.getPara meter("extnno") ;
String lotusmailid=req uest.getParamet er("lotusmailid ");
String personalmailid= request.getPara meter("personal mailid");
String pplmanager=requ est.getParamete r("pplmanager") ;
String projectmanager= request.getPara meter("projectm anager");
String hrid=request.ge tParameter("hri d");
String unixlogin=reque st.getParameter ("unixlogin" );
String attuid=request. getParameter("a ttuid");
String portnum=request .getParameter(" portno");
String address=request .getParameter(" address");
String city=request.ge tParameter("cit y");
String state=request.g etParameter("st ate");
String pincode=request .getParameter(" pincode");
String mobnum=request. getParameter("m obno");
String homenum=request .getParameter(" hometelno");
String project=request .getParameter(" project");
String teamleader=requ est.getParamete r("teamleader") ;
out.println("EM P ID IS:"+empid);
try
{
Class.forName(" sun.jdbc.odbc.J dbcOdbcDriver") ;
Connection con =DriverManager. getConnection(" jdbc:odbc:giom" );
System.out.prin tln("GOT CONNECTION FOR EMPLOYEE UPDATE HANDLER ");
Statement s = con.createState ment();
System.out.prin tln("GOT CONNECTION yaar");
String sql = "UPDATE EMPLOYEE SET FNAME='"+ firstname +"', LNAME='"+ lastname +"', OFF_EMAIL='"+ lotusmailid +"',PRSNL_EMAIL ='"+ personalmailid +"',PPL_MANAGER ='"+ pplmanager +"',PROJECT_MAN AGER='"+ projectmanager +"',EXTN='"+ extnnum +"',PROJECT= '"+ project+"',TEAM _LEADER='"+ teamleader +"',HRID='"+ hrid +"',ATT_UID= '"+ attuid +"',UNIX_LOGIN= '"+ unixlogin+"',PO RT_NO='"+ portnum+"',MOBI LE_NO='"+ mobnum +"',HOME_NO= '"+ homenum +"',CONT_ADDR=' "+ address +"',CITY='"+ city +"',STATE='" + state +"',PINCODE= '"+ pincode +"' WHERE EMP_ID='"+ empid +"'" ;
int i = s.executeUpdate (sql);
System.out.prin tln("i value is :"+i);
if (i!= 0)
{
String message = "Successful ly deleted"+i+" users.";
System.out.prin tln(message);
out.println(mes sage);
}
}
catch (ClassNotFoundE xception e) {
System.out.prin tln(e.toString( ));
}
catch (SQLException e) {
e.printStackTra ce();
}
catch (Exception e) {
System.out.prin tln(e.toString( ));
}
}
I am facing problem with updating a record .actullay im getting some data from database(Access ) and populating it on a html form.im trying to edit some texts and update, its not reflecting in database. here is the code.
(the request parameters from html form, there is no mismatch between variable names)
*************** *************** *************** *************** *************** *************** **private void updateEmployee( HttpServletRequ est request, HttpServletResp onse response) throws IOException{
PrintWriter out = response.getWri ter();
String firstname=reque st.getParameter ("firstname" );
String lastname=reques t.getParameter( "lastname") ;
String empid=request.g etParameter("em pid");
String extnnum = request.getPara meter("extnno") ;
String lotusmailid=req uest.getParamet er("lotusmailid ");
String personalmailid= request.getPara meter("personal mailid");
String pplmanager=requ est.getParamete r("pplmanager") ;
String projectmanager= request.getPara meter("projectm anager");
String hrid=request.ge tParameter("hri d");
String unixlogin=reque st.getParameter ("unixlogin" );
String attuid=request. getParameter("a ttuid");
String portnum=request .getParameter(" portno");
String address=request .getParameter(" address");
String city=request.ge tParameter("cit y");
String state=request.g etParameter("st ate");
String pincode=request .getParameter(" pincode");
String mobnum=request. getParameter("m obno");
String homenum=request .getParameter(" hometelno");
String project=request .getParameter(" project");
String teamleader=requ est.getParamete r("teamleader") ;
out.println("EM P ID IS:"+empid);
try
{
Class.forName(" sun.jdbc.odbc.J dbcOdbcDriver") ;
Connection con =DriverManager. getConnection(" jdbc:odbc:giom" );
System.out.prin tln("GOT CONNECTION FOR EMPLOYEE UPDATE HANDLER ");
Statement s = con.createState ment();
System.out.prin tln("GOT CONNECTION yaar");
String sql = "UPDATE EMPLOYEE SET FNAME='"+ firstname +"', LNAME='"+ lastname +"', OFF_EMAIL='"+ lotusmailid +"',PRSNL_EMAIL ='"+ personalmailid +"',PPL_MANAGER ='"+ pplmanager +"',PROJECT_MAN AGER='"+ projectmanager +"',EXTN='"+ extnnum +"',PROJECT= '"+ project+"',TEAM _LEADER='"+ teamleader +"',HRID='"+ hrid +"',ATT_UID= '"+ attuid +"',UNIX_LOGIN= '"+ unixlogin+"',PO RT_NO='"+ portnum+"',MOBI LE_NO='"+ mobnum +"',HOME_NO= '"+ homenum +"',CONT_ADDR=' "+ address +"',CITY='"+ city +"',STATE='" + state +"',PINCODE= '"+ pincode +"' WHERE EMP_ID='"+ empid +"'" ;
int i = s.executeUpdate (sql);
System.out.prin tln("i value is :"+i);
if (i!= 0)
{
String message = "Successful ly deleted"+i+" users.";
System.out.prin tln(message);
out.println(mes sage);
}
}
catch (ClassNotFoundE xception e) {
System.out.prin tln(e.toString( ));
}
catch (SQLException e) {
e.printStackTra ce();
}
catch (Exception e) {
System.out.prin tln(e.toString( ));
}
}
Comment