I am trying to update the table emp_details. I had written a html form for
taking the input from the user, a
jsp file for forwarding the request to a bean and a bean for updating a record of the emp_details table. When i
test them in the server no error is coming. But the database is not updating.Here is the bean . Is the sql query written for updation is not correct.If yes then how should i write this query.
package bean;
import java.sql.*;
public class EmployeeInfoBean{
private
String employeename,temporaryaddress,permanentaddress,emailaddress;
private int employeeno,departmentid,designationid,telephoneno,skillsetid;
public void setEmployeename(String input)
{
employeename=input;
}
public String getEmployeename()
{
return employeename;
}
public void setTemporaryaddress(String input)
{
temporaryaddress=input;
}
public String getTemporaryaddress()
{
return temporaryaddress;
}
public void setPermanentaddress(String input)
{
permanentaddress=input;
}
public String getPermanentaddress()
{
return permanentaddress;
}
public void setEmailaddress(String input)
{
emailaddress=input;
}
public String getEmailaddress()
{
return emailaddress;
}
public void setTelephoneno(int input)
{
telephoneno=input;
}
public int getTelephoneno()
{
return telephoneno;
}
public void setEmployeeno(int input)
{
employeeno=input;
}
public int getEmployeeno()
{
return employeeno;
}
public void setDepartmentid(int input)
{
departmentid=input;
}
public int getDepartmentid()
{
return departmentid;
}
public void setDesignationid(int input)
{
designationid=input;
}
public int getDesignationid()
{
return designationid;
}
public void setSkillsetid(int input)
{
skillsetid=input;
}
public int getSkillsetid()
{
return skillsetid;
}
public void updateDatabase(){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection conn=
DriverManager.getConnection("jdbc
dbc:employee1","","");
String sql ="UPDATE emp_details SET" + "employeename=?,temporaryaddress=?, permanentaddress=?,emailaddress=?, telephoneno=?, departmentid=?, designationid=?, skillsetid=? where employeeno=?";
PreparedStatement statement=conn.prepareStatement(sql);
statement.setInt(1, employeeno);
statement.setString(2, employeename);
statement.setString(3, temporaryaddress);
statement.setString(4, permanentaddress);
statement.setInt(5, telephoneno);
statement.setString(6, emailaddress);
statement.setInt(7, skillsetid);
statement.setInt(8, departmentid);
statement.setInt(9, designationid);
statement.executeQuery();
}
catch (Exception e){}
}
}